GWicke has submitted this change and it was merged.

Change subject: WTS: More robust handling of zero-child case in 
serializeChildren
......................................................................


WTS: More robust handling of zero-child case in serializeChildren

* If a node has a no children, pass the node itself as the
  lastSourceSep node into chunk callbacks.

* This patch also makes WTS more robust and doesn't rely on
  the DOM pass stripping out auto-inserted empty nodes in snippets
  like:
-----------
{|
|-
{{echo|<tr><td>foo</td></tr>}}
|}
-----------

* Fixes regression on this snippet (with leading whitespace) from
  en:4WD.
-----------
 {|
 |
 | a
 |}
-----------

* Also fixes RT errors for this snippet from:
  en:I Know why the Caged Bird Sings
-----------
<blockquote>a
<p>b</blockquote>
-----------

* This fixes semantic errors on both enwp pages above.

* No change in parser tests (TODO: add more tests).

Change-Id: I01788e7ad96c8ac6b3a20434f77d3dd5ccb94d20
---
M js/lib/mediawiki.DOMPostProcessor.js
M js/lib/mediawiki.WikitextSerializer.js
2 files changed, 6 insertions(+), 2 deletions(-)

Approvals:
  GWicke: Verified; Looks good to me, approved
  jenkins-bot: Verified



diff --git a/js/lib/mediawiki.DOMPostProcessor.js 
b/js/lib/mediawiki.DOMPostProcessor.js
index 995c558..1f2a9e7 100644
--- a/js/lib/mediawiki.DOMPostProcessor.js
+++ b/js/lib/mediawiki.DOMPostProcessor.js
@@ -1601,7 +1601,7 @@
                                                deleteNode(c);
                                        }
                                } else if (dp.autoInsertedStart && 
dp.autoInsertedEnd && c.childNodes.length === 0) {
-                                       // DEle
+                                       // Delete any node that was inserted as 
a fixup node but has no content
                                        deleteNode(c);
                                } else {
                                        findDeletedStartTagsAndMore(c);
diff --git a/js/lib/mediawiki.WikitextSerializer.js 
b/js/lib/mediawiki.WikitextSerializer.js
index 6edf96e..19a46df 100644
--- a/js/lib/mediawiki.WikitextSerializer.js
+++ b/js/lib/mediawiki.WikitextSerializer.js
@@ -402,7 +402,11 @@
 
                // Force out accumulated separator
                if (oldSep === this.sep) {
-                       chunkCB('', children.last());
+                       if (children.length === 0) {
+                               chunkCB('', node);
+                       } else {
+                               chunkCB('', children.last());
+                       }
                }
 
                this.chunkCB = oldCB;

-- 
To view, visit https://gerrit.wikimedia.org/r/57024
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I01788e7ad96c8ac6b3a20434f77d3dd5ccb94d20
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <ssas...@wikimedia.org>
Gerrit-Reviewer: GWicke <gwi...@wikimedia.org>
Gerrit-Reviewer: Subramanya Sastry <ssas...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to