Closed
Bug 1475332
Opened 7 years ago
Closed 7 years ago
Custom Elements Builtins w/out is=""
Categories
(Core :: DOM: Core & HTML, defect, P2)
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>
Reporter | ||
Comment 1•7 years ago
|
||
> 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.
Comment 2•7 years ago
|
||
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
Reporter | ||
Comment 3•7 years ago
|
||
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
Comment 4•7 years ago
|
||
Edgar said he'd take a look. Thanks for the report, Andrea.
Comment hidden (obsolete) |
Comment 6•7 years ago
|
||
Creating elements using JS should not add 'is' attribute.
Looks like Chrome is doing wrong here.
Reporter | ||
Comment 7•7 years ago
|
||
(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?
Comment 8•7 years ago
|
||
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: 7 years ago
Resolution: --- → INVALID
Reporter | ||
Comment 9•7 years ago
|
||
(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.
Reporter | ||
Comment 10•7 years ago
|
||
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
Updated•7 years ago
|
Flags: needinfo?(kkumari)
Comment 11•7 years ago
|
||
Could you upload a minimal testcase using Add an Attachement link.
Comment 12•7 years ago
|
||
This testcase shows is= being serialized in both cases.
Am I missing something?
Flags: needinfo?(andrea.giammarchi)
Reporter | ||
Comment 13•7 years ago
|
||
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)
Reporter | ||
Comment 14•7 years ago
|
||
I can confirm even your attached page shows that output.
Reporter | ||
Comment 15•7 years ago
|
||
this screenshot shows the issue.
Comment 16•7 years ago
|
||
And I'm testing very latest Nightly built from mozilla-inbound and see
<div is="my-div"></div> twice.
Reporter | ||
Comment 17•7 years ago
|
||
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
Reporter | ||
Comment 18•7 years ago
|
||
FYI latest Firefox Developer Edition still shows the issue here.
Comment 19•7 years ago
|
||
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.
Assignee | ||
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•