1
1
mirror of https://github.com/github/semantic.git synced 2024-12-26 08:25:19 +03:00

beginningOfNextElement should be a non-invisible element

This commit is contained in:
joshvera 2015-11-02 15:56:12 -05:00
parent 7331e387ff
commit c3a2e50baf

14
prototype/UI/diff.js vendored
View File

@ -385,8 +385,13 @@ function rollToDOM(sources, rollOrTerm, getRangeFun, diffToDOMFun) {
var nextIndex = befores.indexOf(a) + 1; var nextIndex = befores.indexOf(a) + 1;
if (childElA.classList.contains("invisible") && nextIndex < afters.length) { if (childElA.classList.contains("invisible") && nextIndex < afters.length) {
var beginningOfNextElement = afters[nextIndex].range[0]; var nextVisibleElement = afters[nextIndex]
while (nextVisibleElement.child.classList.contains("invisible") && nextIndex++ < afters.length) {
nextVisibleElement = afters[nextIndex]
}
if (nextVisibleElement == null) break;
var beginningOfNextElement = nextVisibleElement.range[0];
var text = sources.after.substr(previousB, beginningOfNextElement - previousB); var text = sources.after.substr(previousB, beginningOfNextElement - previousB);
var node = wrap("span", document.createTextNode(text)); var node = wrap("span", document.createTextNode(text));
node.classList.add("invisible"); node.classList.add("invisible");
@ -394,8 +399,13 @@ function rollToDOM(sources, rollOrTerm, getRangeFun, diffToDOMFun) {
} }
if (childElB.classList.contains("invisible") && nextIndex < befores.length) { if (childElB.classList.contains("invisible") && nextIndex < befores.length) {
var beginningOfNextElement = befores[nextIndex].range[0]; var nextVisibleElement = befores[nextIndex]
while (nextVisibleElement.child.classList.contains("invisible") && nextIndex++ < befores.length) {
nextVisibleElement = befores[nextIndex]
}
if (nextVisibleElement == null) break;
var beginningOfNextElement = nextVisibleElement.range[0];
var text = sources.before.substr(previousA, beginningOfNextElement - previousA); var text = sources.before.substr(previousA, beginningOfNextElement - previousA);
var node = wrap("span", document.createTextNode(text)); var node = wrap("span", document.createTextNode(text));
node.classList.add("invisible"); node.classList.add("invisible");