From 20d7cf34b2d6ea7adcf80462a52d8a5d1cb26c54 Mon Sep 17 00:00:00 2001 From: Esteban Beltran Date: Mon, 24 Jul 2023 17:23:40 +0200 Subject: [PATCH] Sandbox: Set the `style` attribute of all `Element` child to be a live target (#72208) --- .../app/features/plugins/sandbox/document_sandbox.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/public/app/features/plugins/sandbox/document_sandbox.ts b/public/app/features/plugins/sandbox/document_sandbox.ts index bad5b8edcf8..183779f4ce4 100644 --- a/public/app/features/plugins/sandbox/document_sandbox.ts +++ b/public/app/features/plugins/sandbox/document_sandbox.ts @@ -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, {}); } }