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 comment:1
Changed September 07, 2009 01:30PM UTC by comment:2
workaround:
$(x).find('item').filter(function(){return $(this).text() == 'Dog'});
Changed October 27, 2009 01:01AM UTC by 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 comment:5
component: | unfiled → selector |
---|---|
resolution: | → fixed |
status: | new → closed |
Fixed in jQuery 1.4 (actually in Sizzle).
I think problem is in line 1945 (v1.3.2):
in IE IXMLDOMElement doesn't have properties ''textContent'' and ''innerText'' instead of he has property ''text''.
In jQuery v1.2.6 line 1403:
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()''