Comparing version 0.1.20 to 0.1.21
@@ -69,3 +69,3 @@ "use strict"; | ||
var hasContent = false; | ||
var hasRenderedContent = false; | ||
var newBreakToken = void 0; | ||
@@ -101,3 +101,3 @@ | ||
// Check if the rendered element has a break set | ||
if (hasContent && this.shouldBreak(node)) { | ||
if (hasRenderedContent && this.shouldBreak(node)) { | ||
newBreakToken = this.findBreakToken(wrapper, source, bounds); | ||
@@ -118,4 +118,4 @@ | ||
// Check if layout has content yet | ||
if (!hasContent) { | ||
hasContent = (0, _dom.hasTextContent)(node); | ||
if (!hasRenderedContent) { | ||
hasRenderedContent = (0, _dom.hasContent)(node); | ||
} | ||
@@ -155,3 +155,12 @@ | ||
value: function shouldBreak(node) { | ||
return (0, _dom.needsBreakBefore)(node) || (0, _dom.needsPreviousBreakAfter)(node) || (0, _dom.needsPageBreak)(node); | ||
var previousSibling = node.previousSibling; | ||
var parentNode = node.parentNode; | ||
var parentBreakBefore = (0, _dom.needsBreakBefore)(node) && parentNode && !previousSibling && (0, _dom.needsBreakBefore)(parentNode); | ||
var doubleBreakBefore = void 0; | ||
if (parentBreakBefore) { | ||
doubleBreakBefore = node.dataset.breakBefore === parentNode.dataset.breakBefore; | ||
} | ||
return !doubleBreakBefore && (0, _dom.needsBreakBefore)(node) || (0, _dom.needsPreviousBreakAfter)(node) || (0, _dom.needsPageBreak)(node); | ||
} | ||
@@ -158,0 +167,0 @@ }, { |
@@ -36,2 +36,3 @@ "use strict"; | ||
exports.isVisible = isVisible; | ||
exports.hasContent = hasContent; | ||
exports.hasTextContent = hasTextContent; | ||
@@ -618,2 +619,11 @@ | ||
function hasContent(node) { | ||
if (isElement(node)) { | ||
return true; | ||
} else if (isText(node) && node.textContent.trim().length) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
function hasTextContent(node) { | ||
@@ -620,0 +630,0 @@ if (isElement(node)) { |
{ | ||
"name": "pagedjs", | ||
"version": "0.1.20", | ||
"version": "0.1.21", | ||
"description": "Chunks up a document into paged media flows and applies print styles", | ||
@@ -5,0 +5,0 @@ "author": "Fred Chasen", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
3365213
107995