Closed Bug 1475332 Opened 6 years ago Closed 6 years ago

Custom Elements Builtins w/out is=""

Categories

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

58 Branch
defect

Tracking

()

RESOLVED INVALID

People

(Reporter: andrea.giammarchi, Unassigned)

References

Details

Attachments

(3 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.1 Safari/605.1.15

Steps to reproduce:

class MyDiv extends HTMLDivElement {}
customElements.define('my-div', MyDiv, {extends: 'div'});

console.log((document.body.appendChild(
  document.createElement('div', {is: 'my-div'})
)).outerHTML);

console.log((document.body.appendChild(
  new MyDiv
)).outerHTML);


Actual results:

In Firefox and Firefox Nightly the procedural way shows the attribute but the `new MyDiv` doesn't.

<div is="my-div"></div>
<div></div>

This is very bad for features detection/polyfills purposes.


Expected results:

In Chrome 67+ that produces:

<div is="my-div"></div>
<div is="my-div"></div>
> This is very bad for features detection/polyfills purposes.

That is actually very bad for CSS [is="my-div"] too.

Please normalize the behavior with regular classes too or it's impossible to understand if FF can actually use builtins inherited classes.

Thank you.
I could reproduce this issue on 
User Agent     Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:61.0) Gecko/20100101 Firefox/61.0

I am placing this under Core:DOM so someone from this team can look into this and provide you proper info. Thanks!
Status: UNCONFIRMED → NEW
Component: Untriaged → DOM
Ever confirmed: true
Product: Firefox → Core
Thanks a lot Kanchan, apologies for not having chosen the right team right away but I do hope this gets some priority before Custom Elements will ever ship without the flag or it'll potentially break the Web (or worse, polyfills will keep patching Firefox unable to understand if it's a capable browser).

I'm the author of the document-register-element polyfill used also by Google AMPHTML Project so please don't hesitate to ask me more r ping me again if needed.

Best Regards
Edgar said he'd take a look. Thanks for the report, Andrea.
Flags: needinfo?(echen)
Priority: -- → P2
Creating elements using JS should not add 'is' attribute.
Looks like Chrome is doing wrong here.
(In reply to Olli Pettay [:smaug] (vacation Jul 15->) from comment #6)
> Creating elements using JS should not add 'is' attribute.
> Looks like Chrome is doing wrong here.

that makes no sense. How is CSS based on `[is="my-component"]` going to work with procedurally created nodes?

and why wouldn't developer be able to easily inspect nodes appended through `new MyComponent` ?

if this is a bug, it looks more like a specifications one, not a Chrome one, IMO, wouldn't you agree?
If you think the spec should be changed (back), please file a spec bug.

See
https://html.spec.whatwg.org/#custom-elements-customized-builtin-example
"Note that when creating a customized built-in element programmatically, the is attribute will not be present in the DOM, since it was not explicitly set."

But as of now, this is invalid.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → INVALID
(In reply to Olli Pettay [:smaug] (vacation Jul 15->) from comment #8)
> If you think the spec should be changed (back), please file a spec bug.

done: https://github.com/whatwg/html/issues/3833

> 
> "Note that when creating a customized built-in element programmatically, the
> is attribute will not be present in the DOM, since it was not explicitly
> set."
> 

I've explained why this makes no sense. The constructor is invoked even with elements already available on the DOM so that needing to set the attribute is either redundant / useless or error prone if a dev forgets about it.

Please don't close until it's clear what's the best way to go, because all we have now is inconsistency between the browser that shipped Custom Elements before any other and the soon new comer in the game.

Thanks.
So, it looks like `outerHTML` serialization should show up the `is="..."` attribute regardless, hence make Firefox feature detectable: https://github.com/whatwg/html/issues/3833#issuecomment-406451917
Flags: needinfo?(kkumari)
Could you upload a minimal testcase using Add an Attachement link.
Attached file ce_outer.html
This testcase shows is= being serialized in both cases.
Am I missing something?
Flags: needinfo?(andrea.giammarchi)
I see in console the output I've described in here:
https://codepen.io/WebReflection/pen/JBEYQQ?editors=0011

That is:

<div is="my-div"></div>
<div></div>
Flags: needinfo?(andrea.giammarchi)
I can confirm even your attached page shows that output.
this screenshot shows the issue.
And I'm testing very latest Nightly built from mozilla-inbound and see 
<div is="my-div"></div> twice.
Good, so somebody resolved this bug, but I read RESOLVED INVALID up there so thanks to whoever resolved it, not sure why ti's been flagged as invalid though.

Best Regards
FYI latest Firefox Developer Edition still shows the issue here.
Dev edition is not Nightly. And the code for web components in the current dev edition won't be shipping. Would be better to test Nightly.
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: