fix: detected calling attachShadow
This commit is contained in:
parent
3e0ade9d34
commit
2c2fc6748d
2 changed files with 7 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
import { loadMscore, WebMscore } from './mscore'
|
import { loadMscore, WebMscore } from './mscore'
|
||||||
import { useTimeout, windowOpen, console } from './utils'
|
import { useTimeout, windowOpen, console, _Element } from './utils'
|
||||||
import i18n from './i18n'
|
import i18n from './i18n'
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import btnListCss from './btn.css'
|
import btnListCss from './btn.css'
|
||||||
|
@ -45,6 +45,10 @@ const cloneBtn = (btn: HTMLButtonElement) => {
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const attachShadow = (el: Element): ShadowRoot => {
|
||||||
|
return _Element.prototype.attachShadow.call(el, { mode: 'closed' }) as ShadowRoot
|
||||||
|
}
|
||||||
|
|
||||||
interface BtnOptions {
|
interface BtnOptions {
|
||||||
readonly name: string;
|
readonly name: string;
|
||||||
readonly action: BtnAction;
|
readonly action: BtnAction;
|
||||||
|
@ -94,7 +98,7 @@ export class BtnList {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
}
|
}
|
||||||
const shadow = btnParent.attachShadow({ mode: 'closed' })
|
const shadow = attachShadow(btnParent)
|
||||||
|
|
||||||
// style the shadow DOM
|
// style the shadow DOM
|
||||||
const style = document.createElement('style')
|
const style = document.createElement('style')
|
||||||
|
|
|
@ -49,6 +49,7 @@ export const windowOpen: Window['open'] = (...args): Window | null => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const console: Console = getSandboxWindow()['console']
|
export const console: Console = getSandboxWindow()['console']
|
||||||
|
export const _Element: typeof Element = getSandboxWindow()['Element']
|
||||||
|
|
||||||
export const waitForDocumentLoaded = (): Promise<void> => {
|
export const waitForDocumentLoaded = (): Promise<void> => {
|
||||||
if (document.readyState !== 'complete') {
|
if (document.readyState !== 'complete') {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue