bugzilla.mozilla.org will be intermittently unavailable on Saturday, March 24th, from 16:00 until 20:00 UTC.

document.querySelector() and querySelectorAll() failing




9 years ago
7 years ago


(Reporter: Willy Schott, Unassigned)


Firefox Tracking Flags

(Not tracked)


(Whiteboard: [CLOSEME 2011-1-1])



9 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv: Gecko/20090715 Firefox/3.5.1 (.NET CLR 3.5.30729)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv: Gecko/20090715 Firefox/3.5.1 (.NET CLR 3.5.30729)

Trying to select DOM nodes containing a period character in the id attribute fails. According to http://www.w3.org/TR/html401/types.html#h-6.2 the period is valid in ID and NAME attributes, so Firefox should return the matching nodes.

Reproducible: Always

Steps to Reproduce:
1. Create a valid HTML document containing a node like this:
   <div id="part1.part2"></div>
2. Open the document in Firefox 3.5.1
3. Open a JavaScript console (for example Firebug) and execute:
Actual Results:  

Expected Results:  
<div id="part1.part2">

It might be problematic to distinct between 
<div id="part1.part2"> and
<div id="part1" class="part2">,
but both elements are matching the expression '#part1.part2', and therefore both should be returned in case of doubt, so the application gets the chance to decide.

Comment 1

9 years ago
Presumably you have to escape it (as in \. ) because . is used for class selectors.

Comment 2

9 years ago
Does not work as expected, sorry.
I think \. just tells the JS parser to treat is a plain dot character,
that is, the string of characters that the CSS selector parser sees
is still #part1.part2

I think you have to use  #part1\\.part2 in your example for the CSS parser
to see #part1\.part2 which will match the element.

Inside a <style></style> section, or in a separate CSS file, it should be
sufficient with one backslash though.

Please correct me if I'm wrong.
Reporter, are you still seeing this issue with Firefox 3.6.12 or later in safe mode? If not, please close. These links can help you in your testing.
Also, please consider using the most recent Firefox 4 beta build, your bug may be resolved there.
Whiteboard: [CLOSEME 2011-1-1]
No reply, INCOMPLETE. Please retest with Firefox 3.6.13 or later and a new profile (http://support.mozilla.com/kb/Managing+profiles). If you continue to see this issue with the newest firefox and a new profile, then please comment on this bug.
Last Resolved: 7 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.