Subramanya Sastry has uploaded a new change for review.
https://gerrit.wikimedia.org/r/88521
Change subject: DOM Fragment unpacking: Dont set about on nodes that didnt have
them
......................................................................
DOM Fragment unpacking: Dont set about on nodes that didnt have them
* DOM Fragment unpacking code was setting about attribute as long
as the content-node had a typeOf. But this can set artificially
expand the scope of a transclusion when the fragment came from
wikitext that was part transclusion and part text -- as when
a wikilink text is composed of mixed transclusion and plain text.
This bug fixes regressions on fr:Vasco_Evtimov and other pages
that regression in RT testing.
* Added parser test to capture this scenario.
Change-Id: I348f80817dfcd60768171b98d698a0733d4e6e79
---
M js/lib/dom.t.unpackDOMFragments.js
M js/tests/parserTests.txt
2 files changed, 21 insertions(+), 12 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid
refs/changes/21/88521/1
diff --git a/js/lib/dom.t.unpackDOMFragments.js
b/js/lib/dom.t.unpackDOMFragments.js
index 7b1c604..db12b9e 100644
--- a/js/lib/dom.t.unpackDOMFragments.js
+++ b/js/lib/dom.t.unpackDOMFragments.js
@@ -142,20 +142,19 @@
// Set about and drop wrapper-spans
var n = dummyNode.firstChild;
while (n) {
- var next = n.nextSibling;
+ var next = n.nextSibling,
+ nAbout = n.getAttribute('about');
- // Transfer the about attribute so that it is
still unique in the page
- if (haveOrigType && about !== null) {
+ // If 'n' has an about id already, update it to
the latest one
+ if (haveOrigType && about !== null && nAbout
!== null) {
n.setAttribute('about', about);
- }
-
- // Discard unnecessary span wrappers
- DU.loadDataParsoid(n);
- if (n.data.parsoid.tmp.wrapper &&
- !haveOrigType &&
!n.getAttribute("typeof"))
- {
- DU.migrateChildren(n, n.parentNode, n);
- DU.deleteNode(n);
+ } else {
+ // Discard unnecessary span wrappers
+ DU.loadDataParsoid(n);
+ if (n.data.parsoid.tmp.wrapper &&
!n.getAttribute("typeof")) {
+ DU.migrateChildren(n,
n.parentNode, n);
+ DU.deleteNode(n);
+ }
}
n = next;
diff --git a/js/tests/parserTests.txt b/js/tests/parserTests.txt
index a6dbcc2..7d30674 100644
--- a/js/tests/parserTests.txt
+++ b/js/tests/parserTests.txt
@@ -5096,6 +5096,16 @@
</p>
!! end
+!! test
+Parsoid: Scoped parsing should handle mixed transclusions and plain text
+!! options
+parsoid
+!! input
+[[Foo|{{echo|a}} b]]
+!! result
+<p data-parsoid='{"dsr":[0,20,0,0]}'><a rel="mw:WikiLink" href="Foo"><span
about="#mwt2" typeof="mw:Transclusion"
data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a"}},"i":0}}]}'>a</span>
b</a></p>
+!! end
+
###
### Interwiki links (see maintenance/interwiki.sql)
###
--
To view, visit https://gerrit.wikimedia.org/r/88521
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I348f80817dfcd60768171b98d698a0733d4e6e79
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