-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editorial: use IDL to simplify create an element #751
Conversation
Per whatwg/html#4525 a custom element constructor is required to be an HTMLElement. Also, rather than assume another specification will make foreign namespace objects implement HTMLElement, let's instead assert that does not happen as we cannot test it.
How does this work given the following? customElements.define("x-y", class extends HTMLElement {
constructor() {
return {}; // not a HTMLElement
}
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, IDL's "constructing" checks this after the changes in whatwg/html#4525. So, let's not merge this until that happens, but LGTM in general.
dom.bs
Outdated
<li><p>Assert: <var>result</var>'s <a for=Element>custom element state</a> and | ||
<a for=Element>custom element definition</a> are initialized. | ||
|
||
<li><p>Assert: <var>result</var>'s <a for=Element>namespace</a> is the <a>HTML namespace</a>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's still worth keeping a note why this assert is true: it's because IDL enforced that result is a HTMLElement instance, and at this point in time all HTMLElement instances have the HTML namespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes it sound like it might change to me, but I've added a similar note.
And allow for simplification of "create an element" by moving a step into IDL. Tests: web-platform-tests/wpt#16328. Corresponding DOM changes: whatwg/dom#751. Fixes #4520.
Per whatwg/html#4525 a custom element constructor is required to be an HTMLElement.
Also, rather than assume another specification will make foreign namespace objects implement HTMLElement, let's instead assert that does not happen as we cannot test it.