Subramanya Sastry has uploaded a new change for review.
https://gerrit.wikimedia.org/r/121130
Change subject: Minor code cleanup: Use forEach instead of map where appropriate
......................................................................
Minor code cleanup: Use forEach instead of map where appropriate
* Also replaced buf with newTokens in ext.core.TemplateHandler.js
Change-Id: I81e05a13c9373aa298d710b7942f9fe3cd802e63
---
M lib/dom.t.TableFixups.js
M lib/ext.Cite.js
M lib/ext.core.TemplateHandler.js
M lib/mediawiki.WikitextSerializer.js
M lib/mediawiki.parser.js
5 files changed, 10 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid
refs/changes/30/121130/1
diff --git a/lib/dom.t.TableFixups.js b/lib/dom.t.TableFixups.js
index 15af97c..aea08ea 100644
--- a/lib/dom.t.TableFixups.js
+++ b/lib/dom.t.TableFixups.js
@@ -283,7 +283,7 @@
}
// Remove template encapsulation from other
children. The
// table cell wraps everything now.
- node.childNodes.map(function(childNode) {
+ node.childNodes.forEach(function(childNode) {
if (childNode.getAttribute &&
childNode.getAttribute('about')) {
childNode.removeAttribute('about');
}
diff --git a/lib/ext.Cite.js b/lib/ext.Cite.js
index 6ed8222..c9936cc 100644
--- a/lib/ext.Cite.js
+++ b/lib/ext.Cite.js
@@ -459,7 +459,7 @@
}
if (refGroup) {
- refGroup.refs.map(refGroup.renderLine.bind(refGroup, refsNode));
+ refGroup.refs.forEach(refGroup.renderLine.bind(refGroup,
refsNode));
}
// reset
diff --git a/lib/ext.core.TemplateHandler.js b/lib/ext.core.TemplateHandler.js
index 715d469..4040380 100644
--- a/lib/ext.core.TemplateHandler.js
+++ b/lib/ext.core.TemplateHandler.js
@@ -352,7 +352,7 @@
// Re-join attribute tokens with '=' and '|'
var attribTokens = [];
- attribs.map( function ( kv ) {
+ attribs.forEach( function ( kv ) {
if ( kv.k) {
attribTokens = Util.flattenAndAppendToks(attribTokens,
null, kv.k);
}
@@ -369,7 +369,7 @@
var tokens = ['{{'].concat(attribTokens, ['}}', new defines.EOFTk()]);
// Process exploded token in a new pipeline
- var buf = [];
+ var newTokens = [];
Util.processContentInPipeline(
self.manager.env,
self.manager.frame,
@@ -384,10 +384,10 @@
// EOFTk from every chunk is a big ugly, but
unavoidable
// since EOF token comes with the entire chunk
rather
// than coming through the end event callback.
- buf =
buf.concat(Util.stripEOFTkfromTokens(chunk));
+ newTokens =
newTokens.concat(Util.stripEOFTkfromTokens(chunk));
},
endCB: function() {
- cb({ tokens: buf });
+ cb({ tokens: newTokens });
}
}
);
diff --git a/lib/mediawiki.WikitextSerializer.js
b/lib/mediawiki.WikitextSerializer.js
index 8b02919..fed2af5 100644
--- a/lib/mediawiki.WikitextSerializer.js
+++ b/lib/mediawiki.WikitextSerializer.js
@@ -484,7 +484,7 @@
srcParts[0].template.i = 0;
}
- srcParts.map(function(part) {
+ srcParts.forEach(function(part) {
var tpl = part.template;
if (tpl) { // transclusion: tpl or parser function
var isTpl = typeof(tpl.target.href) === 'string';
diff --git a/lib/mediawiki.parser.js b/lib/mediawiki.parser.js
index db8941e..28b6915 100644
--- a/lib/mediawiki.parser.js
+++ b/lib/mediawiki.parser.js
@@ -373,13 +373,13 @@
*/
ParserPipeline.prototype._applyToStage = function(fn, args) {
// Apply to each stage
- this.stages.map(function(stage) {
+ this.stages.forEach(function(stage) {
if (stage[fn] && stage[fn].constructor === Function) {
stage[fn].apply(stage, args);
}
// Apply to each registered transformer for this stage
if (stage.transformers) {
- stage.transformers.map(function(t) {
+ stage.transformers.forEach(function(t) {
if (t[fn] && t[fn].constructor === Function) {
t[fn].apply(t, args);
}
@@ -389,7 +389,7 @@
// Apply to all known native extensions
var nativeExts = this.env.conf.parsoid.nativeExtensions;
- Object.keys(nativeExts).map(function(extName) {
+ Object.keys(nativeExts).forEach(function(extName) {
var ext = nativeExts[extName];
if (ext[fn] && ext[fn].constructor === Function) {
ext[fn].apply(ext, args);
--
To view, visit https://gerrit.wikimedia.org/r/121130
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I81e05a13c9373aa298d710b7942f9fe3cd802e63
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits