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 16341 - [Templates]: [Non-normative] Clarify that template contents cannot be matched against "selector" queries in their host documents.
Summary: [Templates]: [Non-normative] Clarify that template contents cannot be matched...
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: HISTORICAL - Component Model (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Dimitri Glazkov
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 15476
  Show dependency treegraph
 
Reported: 2012-03-12 22:35 UTC by Dimitri Glazkov
Modified: 2012-10-04 20:51 UTC (History)
4 users (show)

See Also:


Attachments

Description Dimitri Glazkov 2012-03-12 22:35:50 UTC
Raf: You don't mention the goal of isolating template contents from "find"
methods of the containing document, e.g.
document.querySelector/getElementById, CSS rules.
Comment 1 Rafael Weinstein 2012-08-16 18:33:54 UTC
E.g.

document.getElementByTagName("div") won't match div.id == 'foo'.

<template>
  <div id="foo">
</template>

this applies to getElementById, querySelector, querySelectorAll, getElementsByTagName, etc...

One challenge this presents is that DocumentFragment doesn't hvave th
Comment 2 Rafael Weinstein 2012-08-16 18:35:33 UTC
[continued]

One challenge is that while DocumentFragment does have querySelector(All), it doesn't have getElement(s)By*. I don't see why it couldn't, but it doesn't currently.

I'm actually ok with this. querySelectorAll is sufficient for any need. I'm happy filing bugs to add more API to DF later if need be.
Comment 3 Tony Ross [MSFT] 2012-08-16 18:41:24 UTC
(In reply to comment #2)
> [continued]
> 
> One challenge is that while DocumentFragment does have querySelector(All), it
> doesn't have getElement(s)By*. I don't see why it couldn't, but it doesn't
> currently.
> 
> I'm actually ok with this. querySelectorAll is sufficient for any need. I'm
> happy filing bugs to add more API to DF later if need be.

I'd favor enhancing DocumentFragment itself (so sounds like a good bug for DOM4). This would also remove the need to separately declare getElementById and friends on the ShadowRoot interface in the Shadom DOM spec.
Comment 4 Rafael Weinstein 2012-08-16 18:48:00 UTC
So I just asked Ojan about this and the reasoning that this hasn't been done yet is that getElementsBy* return live node lists while querySelectorAll returns a static node list, which is preferred now. So basically, the sentiment is to encourage the use of querySelector* vs getElementsBy*. I'm fine with this. I suppose we could add getElementById if we thought it was really important.

Obviously, everything can be accomplished with selectors, but that's not obvious to alot of webdevs.
Comment 5 Tony Ross [MSFT] 2012-08-16 18:53:08 UTC
That makes sense, though if that's the sentiment should we instead have a bug to remove these APIs from ShadowRoot?
Comment 6 Rafael Weinstein 2012-08-16 19:06:55 UTC
Yep. Probably. +dimitri & dominic
Comment 7 Dimitri Glazkov 2012-08-16 19:16:28 UTC
Yup: https://www.w3.org/Bugs/Public/show_bug.cgi?id=16904
Comment 8 Rafael Weinstein 2012-10-04 20:51:01 UTC
http://dvcs.w3.org/hg/webcomponents/rev/69a61698173c