jenkins-bot has submitted this change and it was merged.
Change subject: DOM Fragment unpacking: Deal with some more nested a-tag
ugliness
......................................................................
DOM Fragment unpacking: Deal with some more nested a-tag ugliness
* When nested-a-tag-generating wikitext shows up in a template,
it spells trouble. The nested a-tag will break up into multiple
a-tags and the dom-fragment unpacker has to make sure that this
doesn't break up encapsulation by adding about-ids appropriately
after the split.
* {{echo|[[Foo|This is [[bad]], very bad]]}}
Before this patch, this snippet would RT as:
{{echo|[[Foo|This is [[bad]], very bad]]}}[[bad]], very bad
The reason is because when the link text is processed in its
own pipeline and the fragment is unpacked, the wikitext is
effectively {{echo|[[Foo|This is ]][[bad]], very bad}}. So,
the unpacker has to make sure that the pieces of the original
link text that moved up one level have encapsulation about
ids as well.
* Fixes RT errors on es:Almeriapedia and he:מרים_רות
Change-Id: Id685d333f78ea8cd230a6911a4898c63e812f080
---
M js/lib/dom.t.unpackDOMFragments.js
1 file changed, 27 insertions(+), 0 deletions(-)
Approvals:
GWicke: Looks good to me, approved
jenkins-bot: Verified
diff --git a/js/lib/dom.t.unpackDOMFragments.js
b/js/lib/dom.t.unpackDOMFragments.js
index 03730fe..db34f83 100644
--- a/js/lib/dom.t.unpackDOMFragments.js
+++ b/js/lib/dom.t.unpackDOMFragments.js
@@ -79,6 +79,19 @@
}
}
+function makeChildrenEncapWrappers(node, about) {
+ DU.addSpanWrappers(node.childNodes);
+
+ var c = node.firstChild;
+ while (c) {
+ // FIXME: This unconditionally sets about on children
+ // This is currently safe since all of them are nested
+ // inside a transclusion, but do we need future-proofing?
+ c.setAttribute("about", about);
+ c = c.nextSibling;
+ }
+}
+
/**
* DOMTraverser handler that unpacks DOM fragments which were injected in the
* token pipeline.
@@ -227,6 +240,20 @@
var timestamp = (new Date()).toString();
fragmentParent.replaceChild(node.ownerDocument.createTextNode(timestamp), node);
+ // If fragmentParent has an about, it
presumably is nested inside a template
+ // Post fixup, its children will surface to the
encapsulation wrapper level.
+ // So, we have to fix them up so they dont
break the encapsulation.
+ //
+ // Ex: {{echo|[[Foo|This is [[bad]], very
bad]]}}
+ //
+ // In this example, the <a> corresponding to
Foo is fragmentParent and has an about
+ // dummyNode is the DOM corresponding to "This
is [[bad]], very bad". Post-fixup
+ // [[bad], very bad are at encapsulation level
and need about ids.
+ about = fragmentParent.getAttribute("about");
+ if (about !== null) {
+ makeChildrenEncapWrappers(dummyNode,
about);
+ }
+
var newDoc =
DU.parseHTML(fragmentParent.outerHTML.replace(timestamp, dummyNode.innerHTML));
DU.migrateChildrenBetweenDocs(newDoc.body,
fragmentParent.parentNode, fragmentParent);
--
To view, visit https://gerrit.wikimedia.org/r/89387
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id685d333f78ea8cd230a6911a4898c63e812f080
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits