Custom elements stop working when moving them between frames
Categories
(Core :: DOM: Core & HTML, defect, P2)
Tracking
()
People
(Reporter: david.kocsis, Assigned: avandolder)
References
(Blocks 7 open bugs)
Details
Attachments
(1 file)
Comment 1•7 years ago
|
||
Updated•7 years ago
|
Comment 2•7 years ago
|
||
Updated•7 years ago
|
Updated•7 years ago
|
Comment 4•4 years ago
|
||
Edgar, thanks for looking into this (and finding this bug!). I would suggest that we attempt a generic solution here (i.e., no prototype changes during adoption, regardless of the type of node) and not scope it to custom elements.
Updated•3 years ago
|
| Assignee | ||
Comment 7•2 years ago
|
||
Previously, nodes that were being adopted into a new document were
given the default prototype for that node from the new document. With
custom elements, however, the new document will not contain the
necessary prototype, and instead an HTMLUnknownElement prototype was
being given. Instead, use a wrapper around the original prototype.
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Comment 10•1 year ago
|
||
I've the same issue in my designer application https://node-projects.github.io/web-component-designer-demo/index.html
You can undock a window to a new browser window (rightclick on the header), but in firefox it does not work, cause I heavily use webcomponents.
Updated•1 year ago
|
Updated•1 year ago
|
Comment 11•1 year ago
|
||
Here's a workaround, for anyone that needs it:
function checkElementPrototype(el) {
if (el instanceof FirefoxFixer) return;
const constructor = customElements.get(el.tagName.toLowerCase());
Object.setPrototypeOf(el, constructor.prototype);
}
class FirefoxFixer extends HTMLElement {
adoptedCallback() {
checkElementPrototype(this);
}
disconnectedCallback() {
checkElementPrototype(this);
}
}
If you extend FirefoxFixer, and make sure you call the super methods in disconnectedCallback and adoptedCallback, it works around the bug.
Here's a demo https://static-misc-4.glitch.me/iframe-ce/
Comment 12•11 months ago
|
||
(This is a specific variant of more general bug 1470017, it seems the plan was to fix this one before fixing the general bug per https://bugzilla.mozilla.org/show_bug.cgi?id=1419329#c4)
Description
•