Side navigation
#6672 closed bug (wontfix)
Opened June 15, 2010 10:39AM UTC
Closed October 02, 2010 03:45AM UTC
Selectors not working properly for textNodes
Reported by: | sharad.banka@gmail.c | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | 1.4.3 |
Component: | selector | Version: | 1.4.2 |
Keywords: | TextNodes, filter | Cc: | |
Blocked by: | Blocking: |
Description
Hi, I am facing problems regarding selectors with text Node.
I have a sample page like:
<body>
Some text
<div id='child'>
Some More Text
</div>
</body>
Now when I run the jQuery command:
$("body").children().remove();
The page still shows "Some text". All the children arent removed. However $("body").contents().remove(), removes all content.
Also when I run this filter:
awp$("body").contents().filter(function() {
return (this.id != 'child');}).remove();
I get the expected output "Some more text".
However
awp$("body").contents().filter('[id!=child]').remove()
even thogh actually the same filter returns a faulty output
"Some text.
Some More text."
Conclusion: The filters dont properly select text Nodes.
Attachments (0)
Change History (1)
Changed October 02, 2010 03:45AM UTC by comment:1
priority: | → undecided |
---|---|
resolution: | → wontfix |
status: | new → closed |
In the above case the text nodes are expected to not be selected. Please note the following based on the official jQuery documentation regarding .children():
"Note also that like most jQuery methods, .children() does not return text nodes; to get all children including text and comment nodes, use .contents()"
This is the currently agreed upon behaviour for .children() and a functional version of the original test with .contents() substituted for this solves the original problem experienced by the ticket submitter.
Test URL: http://jsfiddle.net/gfgEc/
Closing.