Skip to content

What does "implement the HTMLElement interface" means, and how such element can be not in HTML namespace? #1402

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

Closed
kojiishi opened this issue Jun 8, 2016 · 4 comments
Assignees
Labels
topic: custom elements Relates to custom elements (as defined in DOM and HTML)

Comments

@kojiishi
Copy link

kojiishi commented Jun 8, 2016

Step 6.3 of create an element says:

If result does not implement the HTMLElement interface, throw a TypeError.

Is there a definition for this? I'm tentatively checking if the result is a wrapper of a native object of HTMLElement or its subclass. Does this match to what the spec means?

If so, how could I create an element that matches to step 6.8?

If result’s namespace is not the HTML namespace, then throw a NotSupportedError.

I created a test:

class extends HTMLElement {
  constructor() { super(); return document.createElementNS('http://www.w3.org/2000/svg', 'g'); }
}

but this fails in step 6.3.

@domenic @dominiccooney could you advise?

@annevk
Copy link
Member

annevk commented Jun 8, 2016

Is there a definition for this?

See whatwg/webidl#97 for adding one.

@domenic domenic self-assigned this Jun 8, 2016
@domenic domenic added the topic: custom elements Relates to custom elements (as defined in DOM and HTML) label Jun 8, 2016
@domenic
Copy link
Member

domenic commented Jun 8, 2016

Is there a definition for this? I'm tentatively checking if the result is a wrapper of a native object of HTMLElement or its subclass. Does this match to what the spec means?

Yes, this sounds correct. As the spec notes, there's an open issue on trying to define this further.

If so, how could I create an element that matches to step 6.8?

I believe it is not possible to match step 6.8 given the current definition of "element interface".

However, it could eventually be true if, for example, SVG follows up on their intention to make <svg:script> be a HTMLScriptElement. In other words, there is nothing inherently tying together implementing HTMLElement and having the HTML namespace; it happens to be true in the current spec landscape, but is not guaranteed.

@kojiishi
Copy link
Author

kojiishi commented Jun 9, 2016

Thanks for the pointer Anne and clarification Domenic.

I believe it is not possible to match step 6.8 given the current definition of "element interface".

Great, I'll then keep the code but skip the test case for now.

@domenic
Copy link
Member

domenic commented Jun 9, 2016

Great! I'll leave this open to track adding a non-normative note. Something like "as of the time of this writing (June 2016), this is not possible, because X. However, it could become so in the future."

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

No branches or pull requests

3 participants