Subramanya Sastry has uploaded a new change for review.
https://gerrit.wikimedia.org/r/50270
Change subject: Fix crasher in roundtrip-test.js and related bugs.
......................................................................
Fix crasher in roundtrip-test.js and related bugs.
* walkDOM in roundtrip-test.js wasn't testing for undefined
attribs in all cases. This crashed the test on this page:
'Wikipedia:Articles for deletion/Log/2007 November 21'
* Now fixed and lets roundtrip-test complete on this page.
* Additionally, some tests were incorrectly testing if (dsr[0])
when it should have been if (dsr[0] !== null) since dsr[0] can
be zero which is a valid value.
Change-Id: Ie9badd1ac98aec8895e06e95d9b1b79f491d4c74
---
M js/tests/roundtrip-test.js
1 file changed, 5 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid
refs/changes/70/50270/1
diff --git a/js/tests/roundtrip-test.js b/js/tests/roundtrip-test.js
index 6f54ded..e83d189 100644
--- a/js/tests/roundtrip-test.js
+++ b/js/tests/roundtrip-test.js
@@ -110,9 +110,11 @@
attribs = element.getAttribute( 'data-parsoid' );
if ( attribs ) {
attribs = JSON.parse( attribs );
+ } else {
+ attribs = {};
}
- if ( attribs && attribs.dsr && attribs.dsr.length ) {
+ if ( attribs.dsr && attribs.dsr.length ) {
start = attribs.dsr[0] || 0;
end = attribs.dsr[1] || sourceLen - 1;
@@ -123,7 +125,7 @@
return { done: true, nodes: [element] };
}
- if ( attribs.dsr[0] && targetRange.start === start &&
end === targetRange.end ) {
+ if ( attribs.dsr[0] !== null && targetRange.start ===
start && end === targetRange.end ) {
return { done: true, nodes: [element] };
} else if ( targetRange.start === start ) {
waitingForEndMatch = true;
@@ -145,7 +147,7 @@
var res = walkDOM(c);
matchedChildren = res ? res.nodes : null;
if ( matchedChildren ) {
- if ( !currentOffset && attribs.dsr &&
attribs.dsr[0] ) {
+ if ( !currentOffset && attribs.dsr &&
(attribs.dsr[0] !== null) ) {
var elesOnOffset = [];
currentOffset = attribs.dsr[0];
// Walk the preceding nodes
without dsr values and prefix matchedChildren
--
To view, visit https://gerrit.wikimedia.org/r/50270
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie9badd1ac98aec8895e06e95d9b1b79f491d4c74
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits