Skip to content
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

Merged
merged 2 commits into from
Apr 15, 2019

Conversation

annevk
Copy link
Member

@annevk annevk commented Apr 12, 2019

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.

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.
@domenic
Copy link
Member

domenic commented Apr 12, 2019

How does this work given the following?

customElements.define("x-y", class extends HTMLElement {
  constructor() {
    return {}; // not a HTMLElement
  }
});

Copy link
Member

@domenic domenic left a 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>.
Copy link
Member

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.

Copy link
Member Author

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.

@domenic domenic added topic: custom elements Relates to custom elements (as defined in DOM and HTML) do not merge yet Pull request must not be merged per rationale in comment labels Apr 12, 2019
annevk added a commit to whatwg/html that referenced this pull request Apr 15, 2019
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.
@annevk annevk removed the do not merge yet Pull request must not be merged per rationale in comment label Apr 15, 2019
@annevk annevk merged commit e4e0ea8 into master Apr 15, 2019
@annevk annevk deleted the annevk/create-an-element-simplification branch April 15, 2019 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: custom elements Relates to custom elements (as defined in DOM and HTML)
Development

Successfully merging this pull request may close these issues.

2 participants