diff options
| author | Igor Minar | 2011-01-07 22:02:23 -0800 |
|---|---|---|
| committer | Igor Minar | 2011-01-10 10:26:55 -0800 |
| commit | 0a6cf70debc6440685af3f9ea96a66450e4f4ed7 (patch) | |
| tree | 3b7e82bedf53960deb5d460532779ec449dd8dfc /test | |
| parent | c79aba92f6b058742c9ae20a9382f6abc68afcea (diff) | |
| download | angular.js-0a6cf70debc6440685af3f9ea96a66450e4f4ed7.tar.bz2 | |
Rename angular.foreach to angular.forEach to make the api consistent.
camelcase is used for other angular functions and forEach is also
used by EcmaScript standard.
- rename the internal as well as the external function name
- tweak the implementation of the function so that it doesn't
clober it self when we extend the angular object with an
object that has a forEach property equal to this forEach function
Closes #85
Diffstat (limited to 'test')
| -rw-r--r-- | test/BrowserSpecs.js | 2 | ||||
| -rw-r--r-- | test/angular-mocks.js | 4 | ||||
| -rw-r--r-- | test/scenario/RunnerSpec.js | 2 | ||||
| -rw-r--r-- | test/scenario/dslSpec.js | 6 | ||||
| -rw-r--r-- | test/scenario/mocks.js | 2 | ||||
| -rw-r--r-- | test/testabilityPatch.js | 15 |
6 files changed, 16 insertions, 15 deletions
diff --git a/test/BrowserSpecs.js b/test/BrowserSpecs.js index a632f2bd..1e5512b0 100644 --- a/test/BrowserSpecs.js +++ b/test/BrowserSpecs.js @@ -7,7 +7,7 @@ describe('browser', function(){ } fakeSetTimeout.flush = function() { - foreach(setTimeoutQueue, function(fn) { + forEach(setTimeoutQueue, function(fn) { fn(); }); }; diff --git a/test/angular-mocks.js b/test/angular-mocks.js index 5a4e1de5..65dfb12f 100644 --- a/test/angular-mocks.js +++ b/test/angular-mocks.js @@ -141,7 +141,7 @@ function MockBrowser() { MockBrowser.prototype = { poll: function poll(){ - angular.foreach(this.pollFns, function(pollFn){ + angular.forEach(this.pollFns, function(pollFn){ pollFn(); }); }, @@ -304,7 +304,7 @@ function TzDate(offset, timestamp) { 'setYear', 'toDateString', 'toJSON', 'toGMTString', 'toLocaleFormat', 'toLocaleString', 'toLocaleTimeString', 'toSource', 'toString', 'toTimeString', 'toUTCString', 'valueOf']; - angular.foreach(unimplementedMethods, function(methodName) { + angular.forEach(unimplementedMethods, function(methodName) { this[methodName] = function() { throw { name: "MethodNotImplemented", diff --git a/test/scenario/RunnerSpec.js b/test/scenario/RunnerSpec.js index 059dd874..5ebe5690 100644 --- a/test/scenario/RunnerSpec.js +++ b/test/scenario/RunnerSpec.js @@ -54,7 +54,7 @@ describe('angular.scenario.Runner', function() { }); it('should publish the functions in the public API', function() { - angular.foreach(runner.api, function(fn, name) { + angular.forEach(runner.api, function(fn, name) { var func; if (name in $window) { func = $window[name]; diff --git a/test/scenario/dslSpec.js b/test/scenario/dslSpec.js index 6551b6fc..71dfde3c 100644 --- a/test/scenario/dslSpec.js +++ b/test/scenario/dslSpec.js @@ -28,7 +28,7 @@ describe("angular.scenario.dsl", function() { }); }; $root.dsl = {}; - angular.foreach(angular.scenario.dsl, function(fn, name) { + angular.forEach(angular.scenario.dsl, function(fn, name) { $root.dsl[name] = function() { return fn.call($root).apply($root, arguments); }; @@ -281,7 +281,7 @@ describe("angular.scenario.dsl", function() { it('should add all jQuery key/value methods', function() { var METHODS = ['css', 'attr']; var chain = $root.dsl.element('input'); - angular.foreach(METHODS, function(name) { + angular.forEach(METHODS, function(name) { expect(angular.isFunction(chain[name])).toBeTruthy(); }); }); @@ -316,7 +316,7 @@ describe("angular.scenario.dsl", function() { 'innerWidth', 'outerWidth', 'position', 'scrollLeft', 'scrollTop', 'offset' ]; var chain = $root.dsl.element('input'); - angular.foreach(METHODS, function(name) { + angular.forEach(METHODS, function(name) { expect(angular.isFunction(chain[name])).toBeTruthy(); }); }); diff --git a/test/scenario/mocks.js b/test/scenario/mocks.js index 5cd2f30a..616e5d63 100644 --- a/test/scenario/mocks.js +++ b/test/scenario/mocks.js @@ -35,7 +35,7 @@ angular.scenario.testing.MockRunner.prototype.on = function(eventName, fn) { angular.scenario.testing.MockRunner.prototype.emit = function(eventName) { var args = Array.prototype.slice.call(arguments, 1); - angular.foreach(this.listeners[eventName] || [], function(fn) { + angular.forEach(this.listeners[eventName] || [], function(fn) { fn.apply(this, args); }); }; diff --git a/test/testabilityPatch.js b/test/testabilityPatch.js index 6cbf91e9..224a8915 100644 --- a/test/testabilityPatch.js +++ b/test/testabilityPatch.js @@ -56,10 +56,10 @@ afterEach(clearJqCache); function clearJqCache(){ var count = 0; - foreachSorted(jqCache, function(value, key){ + forEachSorted(jqCache, function(value, key){ count ++; delete jqCache[key]; - foreach(value, function(value, key){ + forEach(value, function(value, key){ if (value.$element) dump(key, sortedHtml(value.$element)); else @@ -91,7 +91,7 @@ extend(angular, { 'copy': copy, 'extend': extend, 'equals': equals, - 'foreach': foreach, + 'forEach': forEach, 'noop':noop, 'bind':bind, 'toJson': toJson, @@ -103,13 +103,14 @@ extend(angular, { 'isFunction': isFunction, 'isObject': isObject, 'isNumber': isNumber, - 'isArray': isArray + 'isArray': isArray, + 'forEach': forEach }); function sortedHtml(element, showNgClass) { var html = ""; - foreach(jqLite(element), function toString(node) { + forEach(jqLite(element), function toString(node) { if (node.nodeName == "#text") { html += node.nodeValue. replace(/&(\w+[&;\W])?/g, function(match, entity){return entity?match:'&';}). @@ -155,7 +156,7 @@ function sortedHtml(element, showNgClass) { if (node.style) { var style = []; if (node.style.cssText) { - foreach(node.style.cssText.split(';'), function(value){ + forEach(node.style.cssText.split(';'), function(value){ value = trim(value); if (value) { style.push(lowercase(value)); @@ -174,7 +175,7 @@ function sortedHtml(element, showNgClass) { style.sort(); var tmp = style; style = []; - foreach(tmp, function(value){ + forEach(tmp, function(value){ if (!value.match(/^max[^\-]/)) style.push(value); }); |
