Skip to content

Commit 18372ce

Browse files
committed
fixed whitespace text node causing fake dontend when it was nested deeply in what would be the last node of a column
1 parent 6eba191 commit 18372ce

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

samples/issue_36.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
body { font-size: 9pt; }
1313
#wrapper { margin: 0px 100px; }
1414
.wide, .thin { clear:both; }
15+
#overflow { clear:both; }
1516
</style>
1617
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
1718
<script src="../src/jquery.columnizer.js" type="text/javascript" charset="utf-8"></script>
@@ -74,7 +75,7 @@ <h1>Soleat civibus in pri</h1>
7475
<p>Per ne solum vivendo, fabulas dolorem vivendo in pro. Nec duis ignota cotidieque no, an per possit nostrum. Pro detraxit definitionem eu. Vivendo officiis no nam, eu has reque maiestatis percipitur, dolore reprimique accommodare cum ad. No utinam voluptua oportere pri, augue sonet dicant ei sea.</p>
7576
<p>Sit et, an ius nihil apeirian. Eu posse tempor iuvaret cum. No diam dolor sea, postea mnesarchum ne ius, vel no utinam ignota dolores. Malis suscipit accusamus his ne, utinam assentior prodesset ea eam, facer partem antiopam et cum.</p>
7677
</div>
77-
<div class="overflow">
78+
<div id="overflow">
7879
</div>
7980

8081
</div>

samples/issue_44.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
<meta name="author" content="Matt Wilson">
1010
<!-- Date: 2008-07-12 -->
1111
<style>
12-
.column *{ padding: 5px; }
12+
.column div{ padding: 5px; }
13+
.last.column div{ padding-right: 0px; }
14+
.first.column div{ padding-left: 0px; }
1315
.columnas { width: 100%; }
1416
p { text-indent: 10pt; }
1517
p.split { text-indent: 0pt; }

src/jquery.columnizer.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@
296296
split($col, $destroyable, $col, targetHeight);
297297
}
298298

299-
while(checkDontEndColumn($col.contents(":last").length && $col.contents(":last").get(0))){
299+
while($col.contents(":last").length && checkDontEndColumn($col.contents(":last").get(0))){
300300
var $lastKid = $col.contents(":last");
301301
$lastKid.remove();
302302
$destroyable.prepend($lastKid);
@@ -306,9 +306,11 @@
306306
var div = document.createElement('DIV');
307307
while($destroyable[0].childNodes.length > 0){
308308
var kid = $destroyable[0].childNodes[0];
309-
for(var i=0;i<kid.attributes.length;i++){
310-
if(kid.attributes[i].nodeName.indexOf("jQuery") == 0){
311-
kid.removeAttribute(kid.attributes[i].nodeName);
309+
if(kid.attributes){
310+
for(var i=0;i<kid.attributes.length;i++){
311+
if(kid.attributes[i].nodeName.indexOf("jQuery") == 0){
312+
kid.removeAttribute(kid.attributes[i].nodeName);
313+
}
312314
}
313315
}
314316
div.innerHTML = "";
@@ -339,7 +341,12 @@
339341
// text node. ensure that the text
340342
// is not 100% whitespace
341343
if(/^\s+$/.test(dom.nodeValue)){
342-
return true;
344+
//
345+
// ok, it's 100% whitespace,
346+
// so we should return checkDontEndColumn
347+
// of the inputs previousSibling
348+
if(!dom.previousSibling) return false;
349+
return checkDontEndColumn(dom.previousSibling);
343350
}
344351
return false;
345352
}
@@ -434,7 +441,7 @@
434441
// alert("not splitting a dontend");
435442
}
436443

437-
while(checkDontEndColumn($col.contents(":last").length && $col.contents(":last").get(0))){
444+
while($col.contents(":last").length && checkDontEndColumn($col.contents(":last").get(0))){
438445
var $lastKid = $col.contents(":last");
439446
$lastKid.remove();
440447
$destroyable.prepend($lastKid);

0 commit comments

Comments
 (0)