Skip to main content

Bug Tracker

Side navigation

#12358 closed bug (duplicate)

Opened August 21, 2012 01:07AM UTC

Closed August 21, 2012 01:52AM UTC

Attribute value selector fails on XML if it contains pseudoclass

Reported by: dan@greywallsoftware.com Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.0
Keywords: Cc:
Blocked by: Blocking:
Description

In jQuery 1.8.0, if I run a selector against an XML document, and this selector contains a test for an attribute value, and that attribute value contains a jQuery psuedo-class such as :first or :last, the selector fails with an error. Example code:

var xmldoc = $.parseXML('<root><child name="my:first" >text</child></root>');
$("child[name='my:first']", xmldoc)

The error is

Syntax error, unrecognized expression: [name='my

at jquery-1.8.0.js line 4512. jsFiddle example at http://jsfiddle.net/sZsf2/1/

This happens only in 1.8.0, not in earlier versions.

This happens only if the document being searched is XML; HTML is not affected, as far as I can tell. Also, I am not sure it affects _all_ jQuery pseudo-classes, but I did confirm that it does not affect CSS pseudo-classes such as :hover.

Tested in Firefox 3.6 on Mac OS 10.4, Firefox 5 on Mac OS 10.6, and Chrome 21.0 on Mac OS 10.6.

Attachments (0)
Change History (2)

Changed August 21, 2012 01:13AM UTC by dan@greywallsoftware.com comment:1

I forgot to add. The error only appears if the full name of the pseudo-class appears inside the selector. For example, in the above case

$('child[name*="first"]', xmldoc)

would not raise an error and would return a jQuery object wrapping the correct node.

Changed August 21, 2012 01:52AM UTC by dmethvin comment:2

resolution: → duplicate
status: newclosed

Duplicate of #12303.