From 3678625c7c5f944edccacb0f5b7f63eb164c649f Mon Sep 17 00:00:00 2001 From: Chad Weider Date: Tue, 31 Jan 2012 21:20:33 -0800 Subject: [PATCH] Remove dependencies on native `map`. --- static/js/ace.js | 13 ------------- static/js/domline.js | 5 +++-- static/js/domline_client.js | 5 +++-- static/js/linestylefilter.js | 3 ++- static/js/linestylefilter_client.js | 3 ++- static/js/plugins.js | 10 ++++++---- 6 files changed, 16 insertions(+), 23 deletions(-) diff --git a/static/js/ace.js b/static/js/ace.js index 9efb5d74a..4cad6b4f7 100644 --- a/static/js/ace.js +++ b/static/js/ace.js @@ -371,19 +371,6 @@ function Ace2Editor() // (throbs busy while typing) outerHTML.push('', '\x3cscript>\n', outerScript.replace(/<\//g, '<\\/'), '\n\x3c/script>', '
x
'); - if (!Array.prototype.map) Array.prototype.map = function(fun) - { //needed for IE - if (typeof fun != "function") throw new TypeError(); - var len = this.length; - var res = new Array(len); - var thisp = arguments[1]; - for (var i = 0; i < len; i++) - { - if (i in this) res[i] = fun.call(thisp, this[i], i, this); - } - return res; - }; - var outerFrame = document.createElement("IFRAME"); outerFrame.frameBorder = 0; // for IE info.frame = outerFrame; diff --git a/static/js/domline.js b/static/js/domline.js index d89eeb464..8d8c2ea9e 100644 --- a/static/js/domline.js +++ b/static/js/domline.js @@ -27,6 +27,7 @@ // requires: undefined var plugins = require('/plugins').plugins; +var map = require('/ace2_common').map; var domline = {}; domline.noop = function() @@ -145,10 +146,10 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument) var plugins_ = plugins; - plugins_.callHook("aceCreateDomLine", { + map(plugins_.callHook("aceCreateDomLine", { domline: domline, cls: cls - }).map(function(modifier) + }), function(modifier) { cls = modifier.cls; extraOpenTags = extraOpenTags + modifier.extraOpenTags; diff --git a/static/js/domline_client.js b/static/js/domline_client.js index 095307141..87b6ed558 100644 --- a/static/js/domline_client.js +++ b/static/js/domline_client.js @@ -26,6 +26,7 @@ // requires: undefined var plugins = require('/plugins').plugins; +var map = require('/ace2_common').map; var domline = {}; domline.noop = function() @@ -144,10 +145,10 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument) var plugins_ = plugins; - plugins_.callHook("aceCreateDomLine", { + map(plugins_.callHook("aceCreateDomLine", { domline: domline, cls: cls - }).map(function(modifier) + }), function(modifier) { cls = modifier.cls; extraOpenTags = extraOpenTags + modifier.extraOpenTags; diff --git a/static/js/linestylefilter.js b/static/js/linestylefilter.js index 6bb09f07b..d0b5bc6e8 100644 --- a/static/js/linestylefilter.js +++ b/static/js/linestylefilter.js @@ -30,6 +30,7 @@ var Changeset = require('/easysync2').Changeset var plugins = require('/plugins').plugins; +var map = require('/ace2_common').map; var linestylefilter = {}; @@ -305,7 +306,7 @@ linestylefilter.getFilterStack = function(lineText, textAndClassFunc, browser) linestylefilter: linestylefilter, browser: browser }); - hookFilters.map(function(hookFilter) + map(hookFilters, function(hookFilter) { func = hookFilter(lineText, func); }); diff --git a/static/js/linestylefilter_client.js b/static/js/linestylefilter_client.js index 8f1a6bafd..f057e21a2 100644 --- a/static/js/linestylefilter_client.js +++ b/static/js/linestylefilter_client.js @@ -28,6 +28,7 @@ var Changeset = require('/easysync2_client').Changeset var plugins = require('/plugins').plugins; +var map = require('/ace2_common').map; var linestylefilter = {}; @@ -303,7 +304,7 @@ linestylefilter.getFilterStack = function(lineText, textAndClassFunc, browser) linestylefilter: linestylefilter, browser: browser }); - hookFilters.map(function(hookFilter) + map(hookFilters, function(hookFilter) { func = hookFilter(lineText, func); }); diff --git a/static/js/plugins.js b/static/js/plugins.js index 963f055cf..3e226eba1 100644 --- a/static/js/plugins.js +++ b/static/js/plugins.js @@ -25,10 +25,12 @@ var plugins = { if (sep == undefined) sep = ''; if (pre == undefined) pre = ''; if (post == undefined) post = ''; - return plugins.callHook(hookName, args).map(function(x) - { - return pre + x + post - }).join(sep || ""); + var newCallhooks = []; + var callhooks = plugins.callHook(hookName, args); + for (var i = 0, ii = callhooks.length; i < ii; i++) { + newCallhooks[i] = pre + callhooks[i] + post; + } + return newCallhooks.join(sep || ""); } };