Opened 11 years ago
Closed 11 years ago
#11595 closed bug (invalid)
the filter of contents() can't get correct nodes
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.7.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
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 (5)
comment:1 follow-ups: 2 3 Changed 11 years ago by
Owner: | set to 181652432@… |
---|---|
Status: | new → pending |
comment:2 Changed 11 years ago by
Status: | pending → 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 Changed 11 years ago by
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 11 years ago by
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 11 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
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.
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.