Ticket #4243 (closed bug: fixed)
Selector ~ failed
| Reported by: | kanzi | Owned by: | john |
|---|---|---|---|
| Priority: | major | Milestone: | 1.4 |
| Component: | selector | Version: | 1.4a1 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
$("#prev ~ div").css("border", "3px groove blue"); on " http://docs.jquery.com/Selectors/siblings#prevsiblings"
the border of div matched is not blue.
$("#prev ~ div").html() return null.
Change History
comment:2 Changed 4 years ago by igorbarmin
Repost from http://groups.google.com/group/jquery-dev/browse_thread/thread/aa580809104fce79
sample markup
<html>
<head>
<!-- 1.3.2. looks like broken -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<!-- Nightly. works --> <!--
<script type="text/javascript" src="http://code.jquery.com/nightlies/jquery-nightly.js"></script>
--><!-- 1.3.1. works --><!--
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
-->
<script type="text/javascript">
$(document).ready(function(){
console.log($('#prev ~ div').length);/*expecting 1, got zero in
1.3.2*/
});
</script>
</head>
<body>
<div id="prev">1</div>
<div>2</div>
</body>
</html>
proposed fix (by Fabio Buffoni), works for me:
If you need a quick fix, removing the if
if ( sibDir && elem.nodeType === 1 ) { ... }
in dirNode and dirNodeCheck should fix the problem
hope it helps
comment:5 Changed 4 years ago by john
- Status changed from new to closed
- Version changed from 1.3.2 to 1.4a1
- Resolution set to fixed
This appears to be fixed. http://github.com/jeresig/sizzle/commit/ecd57af1b7562dae6f3bddb9b02477f23076e6bb
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

This example is contained on the iframe, so it's OK.
$('#prev~div', $('iframe')[0].contentDocument) works OK there.
But $('#prev~span', $('iframe')[0].contentDocument) doesn't. It's the real bug.