Subramanya Sastry has uploaded a new change for review.
https://gerrit.wikimedia.org/r/69119
Change subject: (Bug 49655): WIP: Transfer tsr from tpl token to reused
expansion
......................................................................
(Bug 49655): WIP: Transfer tsr from tpl token to reused expansion
Change-Id: I0fb2419e6e303e715e85e5c0d91d8cefd63e5c42
---
M js/lib/ext.core.TemplateHandler.js
1 file changed, 18 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid
refs/changes/19/69119/1
diff --git a/js/lib/ext.core.TemplateHandler.js
b/js/lib/ext.core.TemplateHandler.js
index 9e230a0..817c612 100644
--- a/js/lib/ext.core.TemplateHandler.js
+++ b/js/lib/ext.core.TemplateHandler.js
@@ -50,11 +50,11 @@
* wrapper that is later unpacked in the DOMPostProcessor. Used both for
* transclusion and extension content.
*/
-TemplateHandler.prototype.encapsulateExpansionHTML = function(extToken,
expansion) {
+TemplateHandler.prototype.encapsulateExpansionHTML = function(token,
expansion) {
var toks = DU.getWrapperTokens(expansion.nodes),
about = this.manager.env.newAboutId();
- // Assign the HTML fragment to the data-parsoid.html on the first
- // wrapper token.
+
+ // Assign the HTML fragment to the data-parsoid.html on the first
wrapper token.
toks[0].dataAttribs.html = expansion.html;
// Add the DOMFragment type so that we get unwrapped later
toks[0].setAttribute('typeof', 'mw:DOMFragment');
@@ -63,6 +63,21 @@
toks.forEach(function(tok) {
tok.setAttribute('about', about);
});
+
+ // Transfer tsr to the first and the last tokens
+ var tokenTsr = token.dataAttribs ? token.dataAttribs.tsr : null;
+ if (tokenTsr) {
+ var first = toks[0],
+ last = toks[toks.length-1];
+ if (first == last) {
+ first.dataAttribs.tsr = tokenTsr;
+ } else {
+ first.dataAttribs.tsr = [tokenTsr[0], null];
+ last.dataAttribs.tsr = [null, tokenTsr[1]];
+ }
+ }
+ console.warn("HERE: " + JSON.stringify(toks));
+
return toks;
};
--
To view, visit https://gerrit.wikimedia.org/r/69119
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0fb2419e6e303e715e85e5c0d91d8cefd63e5c42
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