Subramanya Sastry has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/70927


Change subject: (Bug 50266) Dont lose Transclusion info when unpacking 
dom-fragments
......................................................................

(Bug 50266) Dont lose Transclusion info when unpacking dom-fragments

* If a dom-fragment also has a mw:Transclusion type, dont unpack
  the dom-fragment.  Just strip the dom-fragment type

* Fixes regressions in the bug report.

* Added a new parser test.

Change-Id: I2de2ba5369026efa24504ca3ef9619e253ff8d5f
---
M js/lib/mediawiki.DOMPostProcessor.js
M js/tests/parserTests.txt
2 files changed, 12 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid 
refs/changes/27/70927/1

diff --git a/js/lib/mediawiki.DOMPostProcessor.js 
b/js/lib/mediawiki.DOMPostProcessor.js
index 108f437..dd534f3 100644
--- a/js/lib/mediawiki.DOMPostProcessor.js
+++ b/js/lib/mediawiki.DOMPostProcessor.js
@@ -2608,8 +2608,8 @@
 
                        var html = node.data.parsoid.html,
                                tsrDelta = node.data.parsoid.tsrDelta;
-                       if (!html) {
-                               // Most likely a multi-part template with an 
extension in its
+                       if (!html || /\bmw:Transclusion\b/.test(typeOf)) {
+                               // Ex: A multi-part template with an extension 
in its
                                // output (possibly passed in as a parameter).
                                //
                                // Example:
@@ -2618,7 +2618,6 @@
                                // Simply remove the mw:DOMFragment typeof for 
now, as the
                                // entire content will still be encapsulated as 
a
                                // mw:Transclusion.
-                               //console.error('no html!', node.data.parsoid);
                                DU.removeTypeOf(node, 'mw:DOMFragment');
                                return true;
                        }
@@ -2684,15 +2683,6 @@
                                        }
                                }
                        }
-
-                       // FIXME: Deal with the case where the DOMFragment node 
is also a
-                       // transclusion. OTOH, dp.html should not be available 
in that case,
-                       // which would cause us to exit early from this method 
(see
-                       // above).
-                       //console.log(typeOf);
-                       //if (/\bmw:Transclusion\b/.test(typeOf)) {
-                       //      DU.addTypeOf(firstChild, 'mw:Transclusion');
-                       //}
 
                        // Move the old content nodes over from the dummyNode
                        while (firstChild) {
diff --git a/js/tests/parserTests.txt b/js/tests/parserTests.txt
index ff0502e..13f486a 100644
--- a/js/tests/parserTests.txt
+++ b/js/tests/parserTests.txt
@@ -14553,6 +14553,16 @@
 <ol about="#mwt7" class="references" 
data-mw='{"name":"references","body":{"extsrc":"<ref name=\"a\">foo</ref>\nThis 
should just get lost."},"attrs":{}}' typeof="mw:Extension/references"><li 
about="#cite_note-a-1" id="cite_note-a-1"><span rel="mw:referencedBy"><a 
href="#cite_ref-a-1-0">↑</a></span> foo</li><li about="#cite_note-b-2" 
id="cite_note-b-2"><span rel="mw:referencedBy"><a 
href="#cite_ref-b-2-0">↑</a></span> bar</li></ol>
 !!end
 
+!!test
+References: 6. <references /> from a transclusion
+!!options
+parsoid
+!!input
+{{echo|<references />}}
+!!result
+<ol class="references" about="#mwt2" typeof="mw:Transclusion" 
data-mw='{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<references
 />"}},"i":0}'></ol>
+!!end
+
 #### ----------------------------------------------------------------
 #### The following section of tests are primarily to test
 #### wikitext escaping capabilities of Parsoid.  Given that

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2de2ba5369026efa24504ca3ef9619e253ff8d5f
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

Reply via email to