fix: detected calling attachShadow

This commit is contained in:
Xmader 2020-11-23 14:36:06 -05:00
parent 3e0ade9d34
commit 2c2fc6748d
No known key found for this signature in database
GPG key ID: A20B97FB9EB730E4
2 changed files with 7 additions and 2 deletions

View file

@ -1,6 +1,6 @@
import { loadMscore, WebMscore } from './mscore'
import { useTimeout, windowOpen, console } from './utils'
import { useTimeout, windowOpen, console, _Element } from './utils'
import i18n from './i18n'
// @ts-ignore
import btnListCss from './btn.css'
@ -45,6 +45,10 @@ const cloneBtn = (btn: HTMLButtonElement) => {
return n
}
const attachShadow = (el: Element): ShadowRoot => {
return _Element.prototype.attachShadow.call(el, { mode: 'closed' }) as ShadowRoot
}
interface BtnOptions {
readonly name: string;
readonly action: BtnAction;
@ -94,7 +98,7 @@ export class BtnList {
} catch (err) {
console.error(err)
}
const shadow = btnParent.attachShadow({ mode: 'closed' })
const shadow = attachShadow(btnParent)
// style the shadow DOM
const style = document.createElement('style')

View file

@ -49,6 +49,7 @@ export const windowOpen: Window['open'] = (...args): Window | null => {
}
export const console: Console = getSandboxWindow()['console']
export const _Element: typeof Element = getSandboxWindow()['Element']
export const waitForDocumentLoaded = (): Promise<void> => {
if (document.readyState !== 'complete') {