jenkins-bot has submitted this change and it was merged.

Change subject: Move findEnclosingTemplateName to DOMUtils
......................................................................


Move findEnclosingTemplateName to DOMUtils

So it can be used in the linter logging to provide the name of the
template that is causing the issue if it is in an transclusion.

Change-Id: I65e7d673729e47d540f14fd34b21dab58ee55599
---
M lib/utils/DOMUtils.js
M lib/wt2html/pp/handlers/cleanup.js
2 files changed, 16 insertions(+), 10 deletions(-)

Approvals:
  Subramanya Sastry: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/utils/DOMUtils.js b/lib/utils/DOMUtils.js
index 08c09cd..c2fbd0e 100644
--- a/lib/utils/DOMUtils.js
+++ b/lib/utils/DOMUtils.js
@@ -2717,6 +2717,21 @@
        }).nodify(cb);
 };
 
+/**
+ * @method
+ *
+ * @param {Object} tplInfo Template info
+ * @return {string}
+ */
+DOMUtils.findEnclosingTemplateName = function(tplInfo) {
+       var dmw = DU.getDataMw(tplInfo.first);
+       if (dmw.parts && dmw.parts.length === 1) {
+               return dmw.parts[0].template.target.wt.trim();
+       } else {
+               return 'Multi-part-template: ' + JSON.stringify(dmw);
+       }
+};
+
 if (typeof module === "object") {
        module.exports.DOMUtils = DOMUtils;
 }
diff --git a/lib/wt2html/pp/handlers/cleanup.js 
b/lib/wt2html/pp/handlers/cleanup.js
index 6b0eea6..3c86dd3 100644
--- a/lib/wt2html/pp/handlers/cleanup.js
+++ b/lib/wt2html/pp/handlers/cleanup.js
@@ -37,15 +37,6 @@
        }
 }
 
-function findEnclosingTemplateName(tplInfo) {
-       var dmw = DU.getDataMw(tplInfo.first);
-       if (dmw.parts && dmw.parts.length === 1) {
-               return dmw.parts[0].template.target.wt.trim();
-       } else {
-               return 'Multi-part-template: ' + JSON.stringify(dmw);
-       }
-}
-
 function stripEmptyElements(node, env, atTopLevel, tplInfo) {
        if (!atTopLevel || !tplInfo || !DU.isElt(node)) {
                return true;
@@ -61,7 +52,7 @@
                node.nodeName in {'TR': 1, 'LI': 1} && node.attributes.length 
=== 0
        ) {
                env.log('warning/empty/' + node.nodeName.toLowerCase(),
-                       'Template', findEnclosingTemplateName(tplInfo),
+                       'Template', DU.findEnclosingTemplateName(tplInfo),
                        'produces stripped empty elements');
                var nextNode = node.nextSibling;
                DU.deleteNode(node);

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I65e7d673729e47d540f14fd34b21dab58ee55599
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Arlolra <abrea...@wikimedia.org>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
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