Closed Bug 1477023 Opened 7 years ago Closed 7 years ago

Some conditions disallowed in element creation phase are unexpectedly allowed if the element is a customized built-in element

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID
Tracking Status
firefox63 --- affected

People

(Reporter: zjz, Unassigned)

References

Details

<!DOCTYPE html> <meta charset="utf-8"> <title>Some conditions disallowed in element creation phase are unexpectedly allowed if the element is a customized built-in element</title> <script> customElements.define("test-case1", class extends HTMLElement { constructor() { super(); // Should not be allowed to have a child in this phase this.textContent = "Test case1: this text is not expected to be displayed"; // Should not be allowed to have an attribute in this phase this.setAttribute("data-test", "test"); // Upon returning, a "NotSupportedError" DOMException should be thrown // due to the two previous operations. // // Refer to Step 6.1.4 and 6.1.5 of creating an element at the spec: // https://dom.spec.whatwg.org/#concept-create-element // // Test result: // Both Firefox trunk and Chrome 67 follow the spec and throws a exception. } }); customElements.define("test-case2", class extends HTMLDivElement { constructor() { super(); // Should not be allowed to have a child in this phase this.textContent = "Test case2: this text is not expected to be displayed"; // Should not be allowed to have an attribute in this phase this.setAttribute("data-test", "test"); // Upon returning, a "NotSupportedError" DOMException should be thrown // due to the two previous operations. // // Refer to Step 6.1.4 and 6.1.5 of creating an element at the spec: // https://dom.spec.whatwg.org/#concept-create-element // // Test result: // Firefox trunk fails to follow the spec, no expcetion is thrown. // Chrome 67 follows the spec and throws a exception. } }, {extends: "div"}); </script> <div is="test-case2"></div> <test-case1></test-case1>
Blocks: 1358989
(In reply to 張俊芝(Zhang Junzhi) from comment #0) > customElements.define("test-case2", class extends HTMLDivElement > { > constructor() > { > super(); > // Should not be allowed to have a child in this phase > this.textContent = "Test case2: this text is not expected to be displayed"; > // Should not be allowed to have an attribute in this phase > this.setAttribute("data-test", "test"); > > // Upon returning, a "NotSupportedError" DOMException should be thrown > // due to the two previous operations. > // > // Refer to Step 6.1.4 and 6.1.5 of creating an element at the spec: > // https://dom.spec.whatwg.org/#concept-create-element > // > // Test result: > // Firefox trunk fails to follow the spec, no expcetion is thrown. > // Chrome 67 follows the spec and throws a exception. > } > }, {extends: "div"}); > </script> > > <div is="test-case2"></div> If I interpret the spec correctly, the built-in element case should refer to step 5 of https://dom.spec.whatwg.org/#concept-create-element, which runs upgrade steps [1] and allow to have an attribute and a child. Look like we do follow the spec, though I am not sure if the spec intent to have inconsistent behavior or it is a spec issue. [1] https://html.spec.whatwg.org/multipage/custom-elements.html#concept-upgrade-an-element
Yeah, we follow the spec. Reporter, if you want to change the spec to be more consistent, please file a spec bug. As of now, this looks invalid.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.