jenkins-bot has submitted this change and it was merged.
Change subject: Fix handleLinkNeighbors return value
......................................................................
Fix handleLinkNeighbors return value
handleLinkNeighbors returned the next node even if no siblings were consumed
for the tail, which caused further processing (unpackDOMFragments currently)
to be skipped for this node.
This broke parsing for
"[[Foo|<math>bar</math>]] [[Bar]]"
This patch makes sure that handleLinkNeighbours only returns the next node to
process if tail nodes were actually consumed. This fixes semantic errors on
en:Richter's_scale without adding an additional DOM pass as implemented in
alternative patch I369de325b79c85317a95869ddc10e1a0884b1ef6.
Change-Id: I8575676fef28a99435745378b62ef0a64f55210b
---
M js/lib/mediawiki.DOMPostProcessor.js
1 file changed, 20 insertions(+), 9 deletions(-)
Approvals:
Subramanya Sastry: Looks good to me, approved
jenkins-bot: Verified
diff --git a/js/lib/mediawiki.DOMPostProcessor.js
b/js/lib/mediawiki.DOMPostProcessor.js
index 29e87cc..ae382b5 100644
--- a/js/lib/mediawiki.DOMPostProcessor.js
+++ b/js/lib/mediawiki.DOMPostProcessor.js
@@ -149,15 +149,25 @@
} else {
if ( result === undefined ) {
// handle children
- if ( child.parentNode !== null &&
- DU.isElt(child) &&
- child.childNodes.length > 0 )
- {
- this.traverse( child );
+ if (child.parentNode === null) {
+ // TODO gwicke: Throw an exception and
pinpoint the faulty
+ // handler.
+
console.error('DOMPostProcessor.traverse: null parentNode! ' +
+ 'Bug in handlers on ' +
child.outerHTML);
+ child = nextChild;
+ } else {
+ if ( DU.isElt(child) &&
+ child.childNodes.length
> 0 )
+ {
+ this.traverse( child );
+ }
+ child = child.nextSibling;
}
+ } else {
+ // Move on to the next child, as determined
before running
+ // handlers.
+ child = nextChild;
}
- // Move on to the next child
- child = nextChild;
}
}
};
@@ -2625,7 +2635,7 @@
}
}
- if ( trail && trail.content ) {
+ if ( trail && trail.content && trail.content.length ) {
for ( ix = 0; ix < trail.content.length; ix++ ) {
node.appendChild( trail.content[ix] );
}
@@ -2636,8 +2646,9 @@
dp.dsr[3] += trail.src.length;
}
}
+ // indicate that the node's tail siblings have been consumed
+ return node;
}
- return node.nextSibling; // indicate that node's siblings have been
mutated
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/66345
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8575676fef28a99435745378b62ef0a64f55210b
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: GWicke <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits