Jdlrobson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/380581 )

Change subject: Hygiene: Break out removeAttributes transformation
......................................................................

Hygiene: Break out removeAttributes transformation

Allow this to be reused in other places. In particular it is needed
in the page summary endpoint to scrub mw-data attributes

Change-Id: Iab348c2a3f44c10f3202e62a27ed4d2538e604b7
---
A lib/transformations/removeAttributes.js
M lib/transforms.js
2 files changed, 12 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/81/380581/1

diff --git a/lib/transformations/removeAttributes.js 
b/lib/transformations/removeAttributes.js
new file mode 100644
index 0000000..4ad2140
--- /dev/null
+++ b/lib/transformations/removeAttributes.js
@@ -0,0 +1,11 @@
+function removeAttributes(doc, selector, attributeArray) {
+    const ps = doc.querySelectorAll(selector) || [];
+    for (let idx = 0; idx < ps.length; idx++) {
+        const node = ps[idx];
+        for (let aa = 0; aa < attributeArray.length; aa++) {
+            node.removeAttribute(attributeArray[aa]);
+        }
+    }
+}
+
+module.exports = removeAttributes;
diff --git a/lib/transforms.js b/lib/transforms.js
index c10dbb1..68d23ec 100644
--- a/lib/transforms.js
+++ b/lib/transforms.js
@@ -19,7 +19,7 @@
 const extractLeadIntroduction = 
require('./transformations/extractLeadIntroduction');
 const flattenElements = require('./transformations/flattenElements');
 const summarize = require('./transformations/summarize');
-
+const _rmAttributes = require( './transformations/removeAttributes')
 const transforms = {};
 
 const NodeType =
@@ -70,16 +70,6 @@
         if (/^\[|]$/.test(node.innerHTML)) {
             const bracket = doc.createTextNode(node.innerHTML);
             node.parentNode.replaceChild(bracket, node);
-        }
-    }
-}
-
-function _rmAttributes(doc, selector, attributeArray) {
-    const ps = doc.querySelectorAll(selector) || [];
-    for (let idx = 0; idx < ps.length; idx++) {
-        const node = ps[idx];
-        for (let aa = 0; aa < attributeArray.length; aa++) {
-            node.removeAttribute(attributeArray[aa]);
         }
     }
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iab348c2a3f44c10f3202e62a27ed4d2538e604b7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to