Declarative Shadow DOM: this.attachInternals().shadowRoot is always null
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox124 | --- | fixed |
People
(Reporter: constantin.schellhammer, Assigned: avandolder)
Details
Attachments
(2 files)
Steps to reproduce:
- add declarative shadow dom custom element with template.shadowrootmode = "closed" or "open"
- register custom element: constructor:
this.attachInternals().shadowRoot
Actual results:
this.attachInternals().shadowRoot
is null
Expected results:
this.attachInternals().shadowRoot
should not be null for both "open" and "closed" shadow roots (Chrome/Edge behave as expected). For "closed" shadow roots this.shadowRoot
is null, too. So this.attachInternals().shadowRoot
is the only way to make a "closed" shadow root interactive.
Comment 1•8 months ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::DOM: Core & HTML' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Comment 2•8 months ago
|
||
We might not be setting the available to element internals to true (https://html.spec.whatwg.org/#parsing-main-inhead:available-to-element-internals)?
Comment 3•8 months ago
|
||
Comment 4•8 months ago
|
||
Reporter: thanks for reporting, it would also really help if you attach a testcase instead of describing the problem in prose.
Updated•8 months ago
|
Reporter | ||
Comment 5•8 months ago
|
||
testcase:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bug 1877025</title>
<script type="module">
customElements.define("custom-element",class extends HTMLElement {
#internals;
constructor() {
super();
this.#internals = this.attachInternals();
console.assert(this.#internals.shadowRoot!==null);
}
})
</script>
</head>
<body>
<custom-element>
<template shadowrootmode="closed">
Bug 1877025
</template>
</custom-element>
</body>
</html>
Assignee | ||
Comment 6•8 months ago
|
||
(In reply to Peter Van der Beken [:peterv] from comment #2)
We might not be setting the available to element internals to true (https://html.spec.whatwg.org/#parsing-main-inhead:available-to-element-internals)?
Ah, since we create the shadow root from the parser, I don't think the element would have a CustomElementData yet, which we check before setting available to element internals.
Assignee | ||
Comment 7•8 months ago
|
||
Updated•8 months ago
|
Comment 8•8 months ago
|
||
Do we need this on beta?
Comment 11•8 months ago
|
||
Backed out for lint failure on shadow-dom/declarative/declarative-shadow-dom-available-to-element-internals.html
Backout link: https://hg.mozilla.org/integration/autoland/rev/6ac6ad4ee06483569b7ac1e6789796a51414f802
Log link: https://treeherder.mozilla.org/logviewer?job_id=446171810&repo=autoland&lineNumber=69
Comment 13•8 months ago
|
||
Comment 14•8 months ago
|
||
bugherder |
Assignee | ||
Updated•8 months ago
|
Description
•