selector api dont work with dom creted by DomParser

RESOLVED INVALID

Status

()

Core
DOM: CSS Object Model
RESOLVED INVALID
8 years ago
8 years ago

People

(Reporter: Andrii Kasian, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

8 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.4) Gecko/20100413 Firefox/3.6.4 (.NET CLR 3.5.30729)
Build Identifier: 

Problem with work (querySelector|querySelectorAll|mozMatchesSelector) with id(#) and class(.) if created by DOMParser


Reproducible: Always

Steps to Reproduce:
alert((new DOMParser).parseFromString('<test><div id="t" /></test>', "text/xml")
					.documentElement
					.querySelector('div[id="t"]')
					.mozMatchesSelector('#t'))


Actual Results:  
false

Expected Results:  
true

in ff 3.6 and ff3.7
The attribute |id| you're using isn't considered to be an "ID-typed attribute" as defined in Selectors Level 3 [1], so the element doesn't match the selector |#t|. This behavior is correct.

[1] <http://www.w3.org/TR/css3-selectors/#id-selectors>
Status: UNCONFIRMED → RESOLVED
Last Resolved: 8 years ago
Resolution: --- → INVALID
And specifically, your <div> node isn't HTML, since you didn't put it in the HTML namespace.  It's just an unknown element, and doesn't have any ID-type attributes associated with it.
You need to log in before you can comment on or make changes to this bug.