Opened 11 years ago
Closed 11 years ago
#12281 closed bug (fixed)
Empty child object
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | high | Milestone: | None |
Component: | traversing | Version: | 1.8.0 |
Keywords: | Cc: | Timmy Willison, dmethvin | |
Blocked by: | Blocking: |
Description
I have a list with 82 entries. After pressing a button I want to cut it in half.
$( 'button' ).on( "click", function() { var elements = 0; $( 'ul' ).each( function() { elements = Math.floor( $( this ).children().length / 2 ); var nextAll = $( this ).children( ":nth-child(" + elements + ")" ).nextAll(); $('<ul>').append(nextAll).insertAfter($( this )); } ); } );
Works perfectly in 1.7 and 1.8 for the first Click on the button.
Keeps generating empty Lists in 1.8 after that while working in 1.7.
Change History (9)
comment:1 Changed 11 years ago by
Owner: | set to jannis.hell@… |
---|---|
Status: | new → pending |
comment:2 Changed 11 years ago by
Resolution: | → invalid |
---|---|
Status: | pending → closed |
Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!
comment:3 Changed 11 years ago by
<!DOCTYPE html> <html> <head> <title></title> <style type="text/css"> <!-- ul{ width:125px; float:left; display:block; } button{ clear:both; display:block; } --> </style> </head> <body> <div> <h2>Mitwirkende</h2> <ul> <li> <a href="#">Ackner, Johannes</a> </li> <li> <a href="#">Adašević, Borivoje</a> </li> <li> <a href="#">Adam, Ines</a> </li> <li> <a href="#">Adam, Christian</a> </li> <li> <a href="#"></a> <a href="#">Addai, Patrick K.</a> <br> <span>Foto: privat</span> </li> <li> <a href="#">Adler, Eric</a> </li> <li> <a href="#"></a> <a href="#">Adler, Silvia</a> <br> <span>Foto: privat</span> </li> <li> <a href="#">Adorján, Johanna</a> </li> <li> <a href="#">Aeckersberg, Tanja</a> </li> <li> <a href="#"></a> <a href="#">Aerni, Urs Heinz</a> <br> <span>Foto: Rainer Haake/Cortex Unit Verlag</span> </li> <li> <a href="#">Aguigah, René</a> </li> <li> <a href="#">Ahlheim, Rose</a> </li> <li> <a href="#">Ahlheim , Klaus </a> </li> <li> <a href="#">Ahlrichs, Domenika</a> </li> <li> <a href="#">Ahrberg, Edda</a> </li> <li> <a href="#"></a> <a href="#">Ahrens, S. F.</a> <br> <span>Foto: Derk Janssen Verlag</span> </li> <li> <a href="#">Ahrens, Maren</a> </li> <li> <a href="#">Ahrndt, Erich</a> </li> <li> <a href="#">Aichinger, Cornelia</a> </li> <li> <a href="#">Aistermann, Cornelia</a> </li> <li> <a href="#">Akrap, Doris</a> </li> <li> <a href="#">Alagjozovski, Robert</a> </li> <li> <a href="#">Albath, Maike</a> </li> <li> <a href="#">Albers, Jürgen</a> </li> <li> <a href="#">Albert, Claudia</a> </li> <li> <a href="#">Albrecht, Jörg</a> </li> <li> <a href="#">Alef, Rob</a> </li> <li> <a href="#">Alexijewitsch, Swetlana</a> </li> <li> <a href="#"></a> <a href="#">Altmann, Andreas</a> <br> <span>Foto: privat</span> </li> <li> <a href="#">Altura, Nessa</a> </li> <li> <a href="#">Alwart, Jenny</a> </li> <li> <a href="#">Amann, Jürg</a> </li> <li> <a href="#">Amelin, Maxim</a> </li> <li> <a href="#">Amend, Christoph</a> </li> <li> <a href="#">Amm, Veronika</a> </li> <li> <a href="#">Amtsberg, Sven</a> </li> <li> <a href="#">Anaconda, Endo</a> </li> <li> <a href="#"></a> <a href="#">Ananda, Gen Kelsang</a> <br> <span>Foto: KMC Deutschland</span> </li> <li> <a href="#">Anaschewitsch, Alexander</a> </li> <li> <a href="#">Anders, Klaus-Peter</a> </li> <li> <a href="#"></a> <a href="#">Anders, Klaus</a> <br> <span>Foto: Jerome Müller Dupage</span> </li> <li> <a href="#">Anders, Veit</a> </li> <li> <a href="#">Anders, Christian </a> </li> <li> <a href="#">Andersen, Frithjof</a> </li> <li> <a href="#">Andersson, Max</a> </li> <li> <a href="#">Andonovski, Venko</a> </li> <li> <a href="#">Andrews, Florian</a> </li> <li> <a href="#">Andruchowytsch, Juri</a> </li> <li> <a href="#">Angele, Michael</a> </li> <li> <a href="#">Angermayer, Karen Christine </a> </li> <li> <a href="#">Annel, Ulf</a> </li> <li> <a href="#">Annel, Ingrid</a> </li> <li> <a href="#">Anrather, Florian</a> </li> <li> <a href="#">Ansfeld, Karin</a> </li> <li> <a href="#"></a> <a href="#">Anton, Karl</a> <br> <span>Foto: privat</span> </li> <li> <a href="#">Apel, Dietmar Martin</a> </li> <li> <a href="#">Apelt, Andreas H.</a> </li> <li> <a href="#">Appelfeller, Uwe</a> </li> <li> <a href="#">Appelmann, Karl-Heinz</a> </li> <li> <a href="#">Apstein-Müller, Ann Catrin</a> </li> <li> <a href="#">Arabin, Inka</a> </li> <li> <a href="#">Arapi, Lindita</a> </li> <li> <a href="#">Arndt, Timotheus</a> </li> <li> <a href="#">Arnold, Runhild</a> </li> <li> <a href="#">Arnold, Günter</a> </li> <li> <a href="#">Arpen</a> </li> <li> <a href="#">Arslani, Merita</a> </li> <li> <a href="#"></a> <a href="#">Artmann, Andreas</a> <br> <span>Foto: privat</span> </li> <li> <a href="#"></a> <a href="#">Arzenheimer, Melanie</a> <br> <span>Foto: privat/chiliverlag</span> </li> <li> <a href="#">Asado, Susie</a> </li> <li> <a href="#">Asbeck, Herbert</a> </li> <li> <a href="#">Aschenbach, Hans-Georg</a> </li> <li> <a href="#">Asel, Harald</a> </li> <li> <a href="#">Asllani, Persida</a> </li> <li> <a href="#">Assmann, Heinz-Dieter</a> </li> <li> <a href="#">Aue, Daniela</a> </li> <li> <a href="#">Auerbacher, Inge</a> </li> <li> <a href="#">Auffermann, Verena</a> </li> <li> <a href="#">Augstein, Tilo</a> </li> <li> <a href="#"></a> <a href="#">Augstein, Jakob</a> <br> <span>Foto: privat</span> </li> <li> <a href="#">Aurich, Margit</a> </li> <li> <a href="#">Aust, Stefan</a> </li> <li> <a href="#"></a> <a href="#">Autschbach, Peter</a> <br> <span>Foto: Manfred Pollert</span> </li> <li> <a href="#">Avanessian, Armen</a> </li> </ul> <button>Halbieren</button> <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.1.min.js"></script> <!--<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.min.js"></script>--> <script> $( 'button' ).on( "click", function() { var elements = 0; $( 'ul' ).each( function() { elements = Math.floor( $( this ).children().length / 2 ); var nextAll = $( this ).children( ":nth-child(" + elements + ")" ).nextAll(); $('<ul>').append(nextAll).insertAfter($( this )); } ); } ); </script> </div> </body> </html>
works in 1.7 but not in 1.8+
comment:4 Changed 11 years ago by
Resolution: | invalid |
---|---|
Status: | closed → reopened |
comment:5 Changed 11 years ago by
Cc: | Timmy Willison dmethvin added |
---|---|
Component: | unfiled → traversing |
Priority: | undecided → high |
Status: | reopened → open |
Confirmed works as expected in jQuery 1.7.2 and broken in 1.8.0 and later. Looks like a problem with :nth-child selector and .children() : http://jsbin.com/izaler/2/edit
comment:6 Changed 11 years ago by
Can someone give a specific description of what is wrong with this demo? I am running it on both -1.7.2 and -git but not seeing any difference in the result. It always breaks the column on the 13th element, "Ahlheim , Klaus".
comment:7 Changed 11 years ago by
yes, do it more than once, you'll see the difference between .7 and .8 then
comment:8 Changed 11 years ago by
seems to be fixed in the git version. In the jquery-1.8.1.min version it was wrong
comment:9 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | open → closed |
Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.
Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/. Open the link and click to "Fork" (in the top menu) to get started.