Skip to main content

Bug Tracker

Side navigation

#5074 closed bug (fixed)

Opened August 19, 2009 01:18PM UTC

Closed June 13, 2010 04:34PM UTC

:Contains does not work with XML data in IE on 1.3.2

Reported by: khofer Owned by:
Priority: major Milestone: 1.4
Component: selector Version: 1.3.2
Keywords: contains selector Cc:
Blocked by: Blocking:
Description

Load any XML data and try to find elements with :contains and it does not work. Works fine in 1.2.6.

<script type="text/javascript" src="http://www.google.com/jsapi"></script>

<script type="text/javascript">

//load jQuery

google.load("jquery", "1.3.2");

</script>

<script type="text/javascript">

$(document).ready(function() {

var x = $('<xml><data><item>Dog</item><item>cat</item></data></xml>');

var items = $(x).find("item:contains('Dog')");

alert(items.length);

});

</script>

Attachments (0)
Change History (5)

Changed September 02, 2009 01:05PM UTC by yazadji comment:1

I think problem is in line 1945 (v1.3.2):

return (elem.textContent || elem.innerText || "").indexOf(match[3]) >= 0;

in IE IXMLDOMElement doesn't have properties ''textContent'' and ''innerText'' instead of he has property ''text''.

In jQuery v1.2.6 line 1403:

contains: function(a,i,m){return a.textContent||a.innerText||jQuery(a).text()||"").indexOf(m[3])>=0;},

In this case I think jQuery(a).text() is resolving this problem.

So, I think for resolving this bug are two ways:

1. add ''|| elem.text''

2. add ''|| jQuery(elem).text()''

Changed September 07, 2009 01:30PM UTC by yazadji comment:2

workaround:

$(x).find('item').filter(function(){return $(this).text() == 'Dog'});

Changed September 15, 2009 08:09AM UTC by till comment:3

Seems to be a duplicate of #1612

Changed October 27, 2009 01:01AM UTC by TFox comment:4

Replying to [comment:1 yazadji]:

I think problem is in line 1945 (v1.3.2): In this case I think jQuery(a).text() is resolving this problem. So, I think for resolving this bug are two ways: 1. add ''|| elem.text'' 2. add ''|| jQuery(elem).text()''

I can confirm the following change to line #1945 corrected the issue

return (elem.textContent || elem.innerText || jQuery(elem).text() || "").indexOf(match[3]) >= 0;

Changed June 13, 2010 04:34PM UTC by dmethvin comment:5

component: unfiledselector
resolution: → fixed
status: newclosed

Fixed in jQuery 1.4 (actually in Sizzle).