-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue #52: chrome bug when declaring web-component from another realm
- Loading branch information
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<body> | ||
<script> | ||
const sourceText = ` | ||
// registering a component in a class that belongs to another realm | ||
top.customElements.define('x-foo', class extends top.HTMLElement { | ||
constructor() { | ||
super(); | ||
this.attachShadow({ mode: 'open' }).innerHTML = '<p>worked!</p>'; | ||
} | ||
}); | ||
`; | ||
const iframe = document.createElement('iframe'); | ||
iframe.setAttribute('sandbox', 'allow-same-origin allow-scripts'); | ||
document.body.appendChild(iframe); | ||
const { contentWindow } = iframe; | ||
contentWindow.eval(sourceText); | ||
// chrome is failing to create elements indirectly | ||
document.body.innerHTML = '<x-foo></x-foo>'; | ||
document.body.appendChild(document.createElement('x-foo')); | ||
// while still works if it is created directly | ||
document.body.appendChild(new (customElements.get('x-foo'))); | ||
</script> | ||
</body> |