This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 25561 - [Explainer]: Use of template in example would result in multiple matching ID tags being generated in the DOM
Summary: [Explainer]: Use of template in example would result in multiple matching ID ...
Status: RESOLVED WONTFIX
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: HISTORICAL - Component Model (show other bugs)
Version: unspecified
Hardware: PC Windows NT
: P2 minor
Target Milestone: ---
Assignee: Dimitri Glazkov
QA Contact: public-webapps-bugzilla
URL: http://w3c.github.io/webcomponents/ex...
Whiteboard:
Keywords:
Depends on:
Blocks: 14949
  Show dependency treegraph
 
Reported: 2014-05-05 20:22 UTC by Denny Caldwell
Modified: 2014-05-06 14:32 UTC (History)
3 users (show)

See Also:


Attachments

Description Denny Caldwell 2014-05-05 20:22:56 UTC
In the "tick-tock-clock-template" example, id tags are used inside of the template. The intended use of this code is to make a reusable component, but reusing this template would result in multiple "hh", "sep" and "mm" tags being inserted into the DOM - something that breaks HTML standards. A fix would be to instead use another attribute, such as class.

So this:

<template id="tick-tock-clock-template">
  <span id="hh"></span>
  <span id="sep">:</span>
  <span id="mm"></span>
</template>

...becomes this:

<template id="tick-tock-clock-template">
  <span class="hh"></span>
  <span class="sep">:</span>
  <span class="mm"></span>
</template>
Comment 1 Jonas Sicking (Not reading bugmail) 2014-05-05 20:39:08 UTC
I definitely don't think that Shadow content should end up in the document's id map. I.e. document.getElementById(x) should never return an element that is in Shadow DOM.

We really have to remove the "All other HTML elements in the shadow trees must behave as if they were part of the document tree" language from the Shadow DOM spec. That's not nearly normative enough. Simply setting the "in document" flag will mean different things in different engines.

I've raised this before and I'm not sure if the fix is still in progress or if people simply disagree. I've not heard anything back yet either way.
Comment 2 Dimitri Glazkov 2014-05-05 21:02:59 UTC
(In reply to Jonas Sicking from comment #1)
> I definitely don't think that Shadow content should end up in the document's
> id map. I.e. document.getElementById(x) should never return an element that
> is in Shadow DOM.

Right. Denny, as Jonas points out, the ids will be in a shadow tree of the element, which means that they will never collide with main document or other instances.

> 
> We really have to remove the "All other HTML elements in the shadow trees
> must behave as if they were part of the document tree" language from the
> Shadow DOM spec. That's not nearly normative enough. Simply setting the "in
> document" flag will mean different things in different engines.
> 
> I've raised this before and I'm not sure if the fix is still in progress or
> if people simply disagree. I've not heard anything back yet either way.

Filed bug 25562.
Comment 3 Denny Caldwell 2014-05-06 12:41:24 UTC
Will they also not collide with ID's of other elements in the shadow DOM?
Comment 4 Dimitri Glazkov 2014-05-06 14:32:15 UTC
(In reply to Denny Caldwell from comment #3)
> Will they also not collide with ID's of other elements in the shadow DOM?

Sure, but there aren't any other IDs in those shadow trees.