Sandbox: Set the style attribute of all Element child to be a live target (#72208)

This commit is contained in:
Esteban Beltran 2023-07-24 17:23:40 +02:00 committed by GitHub
parent a227dcdfcb
commit 20d7cf34b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -79,13 +79,9 @@ export function isDomElement(obj: unknown): obj is Element {
* This is necessary for plugins working with style attributes to work in Chrome
*/
export function markDomElementStyleAsALiveTarget(el: Element) {
if (
// only HTMLElement's (extends Element) have a style attribute
el instanceof HTMLElement &&
// do not define it twice
!Object.hasOwn(el.style, SANDBOX_LIVE_VALUE)
) {
Reflect.defineProperty(el.style, SANDBOX_LIVE_VALUE, {});
const style = Reflect.get(el, 'style');
if (!Object.hasOwn(style, SANDBOX_LIVE_VALUE)) {
Reflect.defineProperty(style, SANDBOX_LIVE_VALUE, {});
}
}