Commit 3a4a2131 authored by Fred Chasen's avatar Fred Chasen

Fix layout next repeat bug

parent 93c1e649
...@@ -71,7 +71,9 @@ class Layout { ...@@ -71,7 +71,9 @@ class Layout {
if (!shallow) { if (!shallow) {
next = after(node, content); next = after(node, content);
walker = walk(next, content); if (next) {
walker = walk(next, content);
}
} }
} else { } else {
...@@ -88,11 +90,15 @@ class Layout { ...@@ -88,11 +90,15 @@ class Layout {
let overflow = this.overflow(this.element); let overflow = this.overflow(this.element);
if (overflow) { if (overflow) {
newBreakToken = this.findBreakToken(overflow); newBreakToken = this.findBreakToken(overflow);
this.removeOverflow(overflow); if (newBreakToken && newBreakToken.node) {
this.removeOverflow(overflow);
}
break; break;
} else { } else {
// Underflow // Underflow
hasOverflow = false; hasOverflow = false;
...@@ -193,7 +199,7 @@ class Layout { ...@@ -193,7 +199,7 @@ class Layout {
let offset = overflow.startOffset; let offset = overflow.startOffset;
let node, ref, parent, index, temp; let node, ref, parent, index, temp;
if (overflow.startContainer.nodeType === 1 && offset) { if (overflow.startContainer.nodeType === 1) {
// node = children.querySelector("[ref='" + overflow.startContainer.childNodes[offset].getAttribute("ref") + "']"); // node = children.querySelector("[ref='" + overflow.startContainer.childNodes[offset].getAttribute("ref") + "']");
temp = overflow.startContainer.childNodes[offset]; temp = overflow.startContainer.childNodes[offset];
...@@ -209,11 +215,6 @@ class Layout { ...@@ -209,11 +215,6 @@ class Layout {
node = parent.childNodes[index]; node = parent.childNodes[index];
offset = 0; offset = 0;
} }
} else if (overflow.startContainer.nodeType === 1) {
// node = children.querySelector("[ref='" + overflow.startContainer.getAttribute("ref") + "']");
ref = overflow.startContainer.getAttribute("ref");
node = this.wrapper.querySelector("[ref='" + ref + "']");
} else { } else {
index = Array.prototype.indexOf.call(overflow.startContainer.parentNode.childNodes, overflow.startContainer); index = Array.prototype.indexOf.call(overflow.startContainer.parentNode.childNodes, overflow.startContainer);
// let parent = children.querySelector("[ref='" + overflow.startContainer.parentNode.getAttribute("ref") + "']"); // let parent = children.querySelector("[ref='" + overflow.startContainer.parentNode.getAttribute("ref") + "']");
...@@ -222,6 +223,10 @@ class Layout { ...@@ -222,6 +223,10 @@ class Layout {
node = parent.childNodes[index]; node = parent.childNodes[index];
} }
if (!node) {
return;
}
return { return {
node, node,
offset offset
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment