Opened 13 years ago
Closed 13 years ago
#5074 closed bug (fixed)
: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>
Change History (5)
comment:1 follow-up: 4 Changed 13 years ago by
comment:2 Changed 13 years ago by
workaround:
$(x).find('item').filter(function(){return $(this).text() == 'Dog'});
comment:4 Changed 13 years ago by
Replying to 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:
add elem.text
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;
comment:5 Changed 13 years ago by
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: