New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 605900 link

Starred by 3 users

Issue metadata

Status: Duplicate
Merged: issue 621172
Owner:
Last visit > 30 days ago
Closed: Feb 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug-Regression



Sign in to add a comment

currentScript.ownerDocument.querySelector only finds queries with lower case IDs

Reported by joopmicr...@gmail.com, Apr 22 2016

Issue description

Chrome Version       : 52.0.2714.0 canary
Other browsers tested:
  52.0.2714.0 canary        ==> FAIL
  50.0.2661.87 m            ==> OK
  49.0.2623.112 m           ==> OK
have tested this issue:
    Firefox: 45.0.1         ==> OK
         IE: 11.212.10586.0 ==> OK

=========================

In canary currentScript.ownerDocument.querySelector or querySelectorAll, only gives queries with tag selection other querySelections fail.

Run the included code from webserver. (I used chrome dev editor any will do)
For FF and IE I included webcomponents-lite to be able to html import.

in canary:
  currentScript.ownerDocument.querySelector('template')        ==> works
  currentScript.ownerDocument.querySelector('template#tempId') ==> doesn't work
  currentScript.ownerDocument.querySelector('#tempId')         ==> doesn't work

in others:
  currentScript.ownerDocument.querySelector('template')        ==> works
  currentScript.ownerDocument.querySelector('template#tempId') ==> works
  currentScript.ownerDocument.querySelector('#tempId')         ==> works

=========================

------------------------- index.html START
<html>
  <head>
    <!--<script src="webcomponents-lite/webcomponents-lite.js"></script>-->
    <link rel="import" href="template.html"/>
  </head>
  <body>	  
  </body>
</html>
------------------------- index.html END

------------------------- template.html START
<template id="tempId">
  <style>
    #tempcont{
      border:1px solid green;
    }
  </style>
  <div id="tempcont">
    Template Content
  </div>
</template>

<script>
  var currentScript = document._currentScript || document.currentScript;
  var doc = currentScript.ownerDocument;

  var founds = {
    'qs_template': doc.querySelector("template"),
    'qs_template#tempId': doc.querySelector("template#tempId"),
    'qs_#tempId':  doc.querySelector('#tempId')
  }
  
  for(var i in founds)
    console[founds[i]?'debug':'error']('querySelector("'+i+'") '+(founds[i]?'':'not ')+'found');
  
</script>
------------------------- template.html END


 
index.html
171 bytes View Download
template.html
587 bytes View Download
Cc: tkonch...@chromium.org
Labels: Needs-Feedback
Tested the same on mac 10.11 chrome version 52.0.2715.0 with the above html files and observed the error in the console. Please find the screenshot

The same is observed in stable version 50.0.2661.87  also 

joopmicroop@, Could you please let us know if this the error you are facing. A screenshot would be more helpful
Screen Shot 2016-04-25 at 3.19.25 PM.png
161 KB View Download
no that is not the problem that I'm facing. The problem you are facing is because you opened the files from local filesystem.
The files need to be served, not opened from local file. I use 'google dev editor' since it has a build in webserver to serve the files but any will do.

The problem is that querySelector and querySelectorAll in currentScript.ownerDocument can't find selectors other than tag name selectors.

The works.png shows the result of working browsers
  chrome 50.0.2661.87 m   ==> OK
  chrome 49.0.2623.112 m  ==> OK
  Firefox: 45.0.1         ==> OK
  IE: 11.212.10586.0      ==> OK

The doesNotWork.png shows the result of chrome 52.0.2714.0 canary

(document._currentScript || document.currentScript).ownerDocument.querySelector("template");        // finds template element
(document._currentScript || document.currentScript).ownerDocument.querySelector("template#tempId"); // does not find template element
(document._currentScript || document.currentScript).ownerDocument.querySelector("#tempId");         // does not find template element
works.png
103 KB View Download
doesNotWork.png
94.0 KB View Download
Project Member

Comment 3 by sheriffbot@chromium.org, Apr 25 2016

Labels: -Needs-Feedback Needs-Review
Owner: tkonch...@chromium.org
Thank you for providing more feedback. Adding requester "tkonchada@chromium.org" for another review and adding "Needs-Review" label for tracking.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Labels: Te-NeedsFurtherTriage
Removing myself as owner as no action required from my end.
Owner: ----
today, tested on chrome 52.0.2717.0 canary which also fails.

Comment 7 by deknu...@gmail.com, May 27 2016

After some testing on current stable Chrome 51.0.2704.63

I found it seems to be related to the casing of the id and the query.

Attached is another testcase and a screenshot from the console output.

There is an element with id 'CaseSensImport' and the query '#CaseSensImport' does not return it.

On the other side we have a query '#CaseInsensImport' which returns the element with lowercase id 'caseinsensimport'

It seems like the query is lowercased before being applied..

index.htm
339 bytes View Download
import.htm
454 bytes View Download
caseSens.PNG
5.3 KB View Download
Components: Blink>CSS
Components: -Blink>CSS Blink>HTML
Labels: -Type-Bug -Pri-3 -Needs-Review -Te-NeedsFurtherTriage OS-All Pri-2 Type-Bug-Regression
Status: Untriaged (was: Unconfirmed)
Summary: currentScript.ownerDocument.querySelector only finds queries with lower case IDs (was: currentScript.ownerDocument.querySelector only finds queries with tag selection)
Confirmed on Chrome 51 stable and 52 beta.

Seeing in console:
querySelector("qs_template") found
querySelector("qs_template#tempId") not found
querySelector("qs_#tempId") not found


After lowercasing tempId in the element and queries I see:
querySelector("qs_template") found
querySelector("qs_template#tempId") found
querySelector("qs_#tempId") found


This seems related to the HTML import on the page.
Components: -Blink>HTML Blink>WebComponents

Comment 11 by tkent@chromium.org, Jul 29 2016

Owner: hayato@chromium.org
Assign hayato@ for triage

Cc: hayato@chromium.org
Owner: kochi@chromium.org
Status: Assigned (was: Untriaged)
HTML Import => kochi@, could you triage this?
Cc: dominicc@chromium.org
alancutter@ do you have any idea why this is a regression?  I don't think so, so if you have any clue, please let me know.

This could be related to/same as  issue 621172 , adding dominicc@ in cc.

Can this be just quirks mode applied to imported document?

Comment 14 Deleted

Comment 15 Deleted

Yes indeed I tested the files of  issue 621172  and they seem to present the same problem. Since there are capitals in the template id the querySelector won't match. Changing it to lowercase results in a match of both querySelector and getElementById.
Components: -Blink>WebComponents Blink>HTML>Modules

Comment 18 by kochi@chromium.org, Feb 24 2017

Mergedinto: 621172
Status: Duplicate (was: Assigned)

Sign in to add a comment