Bug Tracker

Ticket #4208 (closed bug: wontfix)

Opened 6 years ago

Last modified 12 months ago

Selector inconsistency with XML Namespaces

Reported by: janrito Owned by: john
Priority: minor Milestone: 1.next
Component: selector Version: 1.3.2
Keywords: needsreview xml Cc:
Blocking: Blocked by:

Description

On a namespaced xml element like:

<media:thumbnail>

In Firefox it will match with:

jQuery('media
:thumbnail')

This won't match the element in Safari though. In Safari it will match with:

jQuery('thumbnail')

This is a problem, since it will match any element regardless of the namespace:

<media:thumbnail> <dc:thumbnail> <thumbnail>

Firefox won't match any without the namespace. I have been able to match the correct element by checking the node name:

jQuery('item', xml).find('[nodeName="media:thumbnail"]');

Change History

comment:1 Changed 4 years ago by dmethvin

  • Keywords needsreview xml added
  • Status changed from new to open

comment:2 Changed 4 years ago by danheberden

  • Milestone changed from 1.4 to 1.next

Related to #4120

comment:3 Changed 4 years ago by thingsinjars

This might be related to #4120 but this is more about the inconsistency between browsers. There's a test case here:

 http://jsfiddle.net/thingsinjars/xaKLn/

I investigated this one a bit and found that nodes with a namespace created using document.createElement are detectable in IE6/7/8 using an escaped jQuery selector: div.appendChild(document.createElement('a:bc'))

$(div).find('a\\:bc').length // equals 1

But...

The same nodes created with the same namespace are not detectable by IE6/7/8 when they are created with .html():

$('<div/>').html('<a:bc/>').find('a\\:bc').length // equals 0

Instead, those nodes are detectable without the namespace:

$('<div/>').html('<a:bc/>').find('bc').length // equals 1

If there's no consistent way to get around the browser inconsistency, there's an addition to $.support to detect this behaviour in the jsfiddle.

comment:4 Changed 4 years ago by thingsinjars

There's more IE namespace investigation detailed here along with more jsfiddle testcases:

 http://thingsinjars.com/post/371/investigating-ies-innerhtml/

I'm now definitely of the opinion that there isn't a way to patch this odd namespace behaviour in IE6/7/8 and it should be added to $.support.

comment:5 Changed 3 years ago by john

  • Status changed from open to closed
  • Resolution set to wontfix

This isn't something that we're going to fix:  http://docs.jquery.com/Won%27t_Fix

comment:6 Changed 12 months ago by gavenkoa

FYI this page still live:  http://contribute.jquery.org/wont-fix/ (support issues with SVG/WML/etc).

Note: See TracTickets for help on using tickets.