Ticket #11595 (closed bug: invalid)
the filter of contents() can't get correct nodes
| Reported by: | 181652432@… | Owned by: | 181652432@… |
|---|---|---|---|
| Priority: | undecided | Milestone: | None |
| Component: | unfiled | Version: | 1.7.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
example: html:
<p>Hello <a href="http://ejohn.org/">John</a>, how are you doing?</p>
jquery:
$("p").contents().not("[nodeType=1]").wrap("<b/>");
then, the result should be:
<p><b>Hello</b> <a href="http://ejohn.org/">John</a>, <b>how are you doing?</b></p>
but in version 1.7.2, i get the result:
<p>Hello <b><a href="http://ejohn.org/">John</a></b>, how are you doing?</p>
Change History
comment:1 follow-ups: ↓ 2 ↓ 3 Changed 13 months ago by dmethvin
- Owner set to 181652432@…
- Status changed from new to pending
comment:2 in reply to: ↑ 1 Changed 13 months ago by 181652432@…
- Status changed from pending to new
Replying to dmethvin:
That's all kinds of broken. There is no nodeType *attribute* in your markup.
Please provide a jsFiddle.net example of what you are expecting.
I use the webkit browser.When I import the jquery of version 1.5.2, the Example is worked.When i update the jquery to version 1.7.2,it's not work.
I have the html:
<div> menuName <ul> <li>menu1</li> <li>menu2</li> <li>menu3</li> </ul> </div>
I got the menuName when i use the follow script(jquery-1.5.2). script:
$("div").contents().not("[nodeType=1]").text()
but after i updated the jquery 1.7.2, i couldn't get it.
comment:3 in reply to: ↑ 1 Changed 13 months ago by 181652432@…
Replying to dmethvin:
That's all kinds of broken. There is no nodeType *attribute* in your markup.
Please provide a jsFiddle.net example of what you are expecting.
sorry,the comment:2 is not corrent.
so i provide the jsFiddle.net example..
jsFiddle:
example for 1.3.2: http://jsfiddle.net/hY2yL/1/
example for 1.7.2: http://jsfiddle.net/hY2yL/2/
comment:4 Changed 13 months ago by anonymous
See bottom example: http://api.jquery.com/contents/
The selector you're using is for attributes, not properties. I'm guessing the behaviour you're labeling "correct" in version 1.3.2 was actually not intended.
comment:5 Changed 13 months ago by dmethvin
- Status changed from new to closed
- Resolution set to invalid
Agreed with anonymous, the fact that Sizzle grabbed properties as well as attributes was a bug.
Also, in general, jQuery does not support manipulation of text nodes. Many methods may either remove them or fail to work properly with them. Remember that CSS selectors cannot select text nodes.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

That's all kinds of broken. There is no nodeType *attribute* in your markup.
Please provide a jsFiddle.net example of what you are expecting.