Bug Tracker

Opened 7 years ago

Closed 7 years ago

#12358 closed bug (duplicate)

Attribute value selector fails on XML if it contains pseudoclass

Reported by: dan@… 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.

Change History (2)

comment:1 Changed 7 years ago by dan@…

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.

comment:2 Changed 7 years ago by dmethvin

Resolution: duplicate
Status: newclosed

Duplicate of #12303.

Note: See TracTickets for help on using tickets.