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 | |
| 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
| -rw-r--r-- | CHANGELOG.md | 4 | ||||
| -rw-r--r-- | src/Angular.js | 24 | ||||
| -rw-r--r-- | src/AngularPublic.js | 2 | ||||
| -rw-r--r-- | src/Browser.js | 2 | ||||
| -rw-r--r-- | src/Compiler.js | 12 | ||||
| -rw-r--r-- | src/Injector.js | 4 | ||||
| -rw-r--r-- | src/JSON.js | 4 | ||||
| -rw-r--r-- | src/Resource.js | 12 | ||||
| -rw-r--r-- | src/Scope.js | 6 | ||||
| -rw-r--r-- | src/apis.js | 4 | ||||
| -rw-r--r-- | src/directives.js | 2 | ||||
| -rw-r--r-- | src/filters.js | 2 | ||||
| -rw-r--r-- | src/formatters.js | 2 | ||||
| -rw-r--r-- | src/jqLite.js | 10 | ||||
| -rw-r--r-- | src/markups.js | 2 | ||||
| -rw-r--r-- | src/sanitizer.js | 2 | ||||
| -rw-r--r-- | src/scenario/Describe.js | 10 | ||||
| -rw-r--r-- | src/scenario/ObjectModel.js | 2 | ||||
| -rw-r--r-- | src/scenario/Runner.js | 10 | ||||
| -rw-r--r-- | src/scenario/Scenario.js | 4 | ||||
| -rw-r--r-- | src/scenario/SpecRunner.js | 2 | ||||
| -rw-r--r-- | src/scenario/dsl.js | 4 | ||||
| -rw-r--r-- | src/scenario/output/Html.js | 2 | ||||
| -rw-r--r-- | src/scenario/output/Xml.js | 6 | ||||
| -rw-r--r-- | src/services.js | 20 | ||||
| -rw-r--r-- | src/widgets.js | 12 | ||||
| -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 |
32 files changed, 101 insertions, 96 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index a72281dc..0b965c4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,7 +48,9 @@ - In the light of the `eager-published` change, to complete the cleanup we renamed `$creation` property of services to `eager` with its value being a boolean. - To transition, please rename all `$creation: 'eager'` declarations to `$eager: true` + To transition, please rename all `$creation: 'eager'` declarations to `$eager: true`. + +- `angular.foreach` was renamed to `angular.forEach` to make the api consistent. # <angular/> 0.9.8 astral-projection (2010-12-23) # diff --git a/src/Angular.js b/src/Angular.js index 060e08c1..59b031cc 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -115,7 +115,7 @@ var _undefined = undefined, /** * @workInProgress * @ngdoc function - * @name angular.foreach + * @name angular.forEach * @function * * @description @@ -124,10 +124,12 @@ var _undefined = undefined, * `value` is the value of an object property or an array element and `key` is the object property * key or array element index. Optionally, `context` can be specified for the iterator function. * + * Note: this function was previously known as `angular.foreach`. + * <pre> var values = {name: 'misko', gender: 'male'}; var log = []; - angular.foreach(values, function(value, key){ + angular.forEach(values, function(value, key){ this.push(key + ': ' + value); }, log); expect(log).toEqual(['name: misko', 'gender:male']); @@ -138,7 +140,7 @@ var _undefined = undefined, * @param {Object} context Object to become context (`this`) for the iterator function. * @returns {Objet|Array} Reference to `obj`. */ -function foreach(obj, iterator, context) { +function forEach(obj, iterator, context) { var key; if (obj) { if (isFunction(obj)){ @@ -147,7 +149,7 @@ function foreach(obj, iterator, context) { iterator.call(context, obj[key], key); } } - } else if (obj.forEach) { + } else if (obj.forEach && obj.forEach !== forEach) { obj.forEach(iterator, context); } else if (isObject(obj) && isNumber(obj.length)) { for (key = 0; key < obj.length; key++) @@ -160,7 +162,7 @@ function foreach(obj, iterator, context) { return obj; } -function foreachSorted(obj, iterator, context) { +function forEachSorted(obj, iterator, context) { var keys = []; for (var key in obj) keys.push(key); keys.sort(); @@ -197,9 +199,9 @@ function formatError(arg) { * @param {...Object} src The source object(s). */ function extend(dst) { - foreach(arguments, function(obj){ + forEach(arguments, function(obj){ if (obj !== dst) { - foreach(obj, function(value, key){ + forEach(obj, function(value, key){ dst[key] = value; }); } @@ -459,7 +461,7 @@ function isVisible(element) { function map(obj, iterator, context) { var results = []; - foreach(obj, function(value, index, list) { + forEach(obj, function(value, index, list) { results.push(iterator.call(context, value, index, list)); }); return results; @@ -580,7 +582,7 @@ function copy(source, destination){ destination.push(copy(source[i])); } } else { - foreach(destination, function(value, key){ + forEach(destination, function(value, key){ delete destination[key]; }); for ( var key in source) { @@ -778,7 +780,7 @@ function compile(element, parentScope) { */ function parseKeyValue(/**string*/keyValue) { var obj = {}, key_value, key; - foreach((keyValue || "").split('&'), function(keyValue){ + forEach((keyValue || "").split('&'), function(keyValue){ if (keyValue) { key_value = keyValue.split('='); key = unescape(key_value[0]); @@ -790,7 +792,7 @@ function parseKeyValue(/**string*/keyValue) { function toKeyValue(obj) { var parts = []; - foreach(obj, function(value, key) { + forEach(obj, function(value, key) { parts.push(escape(key) + (value === true ? '' : '=' + escape(value))); }); return parts.length ? parts.join('&') : ''; diff --git a/src/AngularPublic.js b/src/AngularPublic.js index ab37a772..ec41d0d9 100644 --- a/src/AngularPublic.js +++ b/src/AngularPublic.js @@ -30,7 +30,7 @@ extend(angular, { 'copy': copy, 'extend': extend, 'equals': equals, - 'foreach': foreach, + 'forEach': forEach, 'injector': createInjector, 'noop':noop, 'bind':bind, diff --git a/src/Browser.js b/src/Browser.js index 377c740c..eb6afb3c 100644 --- a/src/Browser.js +++ b/src/Browser.js @@ -136,7 +136,7 @@ function Browser(window, document, body, XHR, $log) { * @methodOf angular.service.$browser */ self.poll = function() { - foreach(pollFns, function(pollFn){ pollFn(); }); + forEach(pollFns, function(pollFn){ pollFn(); }); }; /** diff --git a/src/Compiler.js b/src/Compiler.js index a18341f4..fdce334c 100644 --- a/src/Compiler.js +++ b/src/Compiler.js @@ -16,8 +16,8 @@ Template.prototype = { init: function(element, scope) { var inits = {}; this.collectInits(element, inits, scope); - foreachSorted(inits, function(queue){ - foreach(queue, function(fn) {fn();}); + forEachSorted(inits, function(queue){ + forEach(queue, function(fn) {fn();}); }); }, @@ -32,7 +32,7 @@ Template.prototype = { scope.$onEval(childScope.$eval); element.data($$scope, childScope); } - foreach(this.inits, function(fn) { + forEach(this.inits, function(fn) { queue.push(function() { childScope.$tryEval(function(){ return childScope.$service(fn, childScope, element); @@ -232,7 +232,7 @@ Compiler.prototype = { for(var i=0, child=element[0].childNodes; i<child.length; i++) { if (isTextNode(child[i])) { - foreach(self.markup, function(markup){ + forEach(self.markup, function(markup){ if (i<child.length) { var textNode = jqLite(child[i]); markup.call(selfApi, textNode.text(), textNode, element); @@ -245,7 +245,7 @@ Compiler.prototype = { if (directives) { // Process attributes/directives eachAttribute(element, function(value, name){ - foreach(self.attrMarkup, function(markup){ + forEach(self.attrMarkup, function(markup){ markup.call(selfApi, value, name, element); }); }); @@ -287,6 +287,6 @@ function eachAttribute(element, fn){ } attrValue[name] = value; } - foreachSorted(attrValue, fn); + forEachSorted(attrValue, fn); } diff --git a/src/Injector.js b/src/Injector.js index f6cb897f..cd9438e7 100644 --- a/src/Injector.js +++ b/src/Injector.js @@ -47,14 +47,14 @@ function createInjector(providerScope, providers, cache) { returnValue = cache[value]; } else if (isArray(value)) { returnValue = []; - foreach(value, function(name) { + forEach(value, function(name) { returnValue.push(inject(name)); }); } else if (isFunction(value)) { returnValue = inject(value.$inject || []); returnValue = value.apply(scope, concat(returnValue, arguments, 2)); } else if (isObject(value)) { - foreach(providers, function(provider, name){ + forEach(providers, function(provider, name){ if (provider.$eager) inject(name); diff --git a/src/JSON.js b/src/JSON.js index 399b2197..0d23314f 100644 --- a/src/JSON.js +++ b/src/JSON.js @@ -53,12 +53,12 @@ function fromJson(json, useNative) { throw e; } - // TODO make foreach optionally recursive and remove this function + // TODO make forEach optionally recursive and remove this function function transformDates(obj) { if (isString(obj) && obj.length === DATE_ISOSTRING_LN) { return angularString.toDate(obj); } else if (isArray(obj) || isObject(obj)) { - foreach(obj, function(val, name) { + forEach(obj, function(val, name) { obj[name] = transformDates(val); }); } diff --git a/src/Resource.js b/src/Resource.js index 570ce1f9..a49dc1c0 100644 --- a/src/Resource.js +++ b/src/Resource.js @@ -4,7 +4,7 @@ function Route(template, defaults) { this.template = template = template + '#'; this.defaults = defaults || {}; var urlParams = this.urlParams = {}; - foreach(template.split(/\W/), function(param){ + forEach(template.split(/\W/), function(param){ if (param && template.match(new RegExp(":" + param + "\\W"))) { urlParams[param] = true; } @@ -17,13 +17,13 @@ Route.prototype = { var self = this; var url = this.template; params = params || {}; - foreach(this.urlParams, function(_, urlParam){ + forEach(this.urlParams, function(_, urlParam){ var value = params[urlParam] || self.defaults[urlParam] || ""; url = url.replace(new RegExp(":" + urlParam + "(\\W)"), value + "$1"); }); url = url.replace(/\/?#$/, ''); var query = []; - foreachSorted(params, function(value, key){ + forEachSorted(params, function(value, key){ if (!self.urlParams[key]) { query.push(encodeURI(key) + '=' + encodeURI(value)); } @@ -52,7 +52,7 @@ ResourceFactory.prototype = { actions = extend({}, ResourceFactory.DEFAULT_ACTIONS, actions); function extractParams(data){ var ids = {}; - foreach(paramDefaults || {}, function(value, key){ + forEach(paramDefaults || {}, function(value, key){ ids[key] = value.charAt && value.charAt(0) == '@' ? getter(data, value.substr(1)) : value; }); return ids; @@ -62,7 +62,7 @@ ResourceFactory.prototype = { copy(value || {}, this); } - foreach(actions, function(action, name){ + forEach(actions, function(action, name){ var isPostOrPut = action.method == 'POST' || action.method == 'PUT'; Resource[name] = function (a1, a2, a3) { var params = {}; @@ -97,7 +97,7 @@ ResourceFactory.prototype = { if (status == 200) { if (action.isArray) { value.length = 0; - foreach(response, function(item){ + forEach(response, function(item){ value.push(new Resource(item)); }); } else { diff --git a/src/Scope.js b/src/Scope.js index 393e015b..e1ea43a1 100644 --- a/src/Scope.js +++ b/src/Scope.js @@ -48,7 +48,7 @@ var scopeId = 0, getterFnCache = {}, compileCache = {}, JS_KEYWORDS = {}; -foreach( +forEach( ("abstract,boolean,break,byte,case,catch,char,class,const,continue,debugger,default," + "delete,do,double,else,enum,export,extends,false,final,finally,float,for,function,goto," + "if,implements,import,ininstanceof,intinterface,long,native,new,null,package,private," + @@ -61,7 +61,7 @@ function getterFn(path){ if (fn) return fn; var code = 'var l, fn, t;\n'; - foreach(path.split('.'), function(key) { + forEach(path.split('.'), function(key) { key = (JS_KEYWORDS[key]) ? '["' + key + '"]' : '.' + key; code += 'if(!s) return s;\n' + 'l=s;\n' + @@ -575,7 +575,7 @@ function createScope(parent, providers, instanceCache) { $become: function(Class) { if (isFunction(Class)) { instance.constructor = Class; - foreach(Class.prototype, function(fn, name){ + forEach(Class.prototype, function(fn, name){ instance[name] = bind(instance, fn); }); instance.$service.apply(instance, concat([Class, instance], arguments, 1)); diff --git a/src/apis.js b/src/apis.js index a73626cf..28b49ed6 100644 --- a/src/apis.js +++ b/src/apis.js @@ -499,7 +499,7 @@ var angularArray = { 'count':function(array, condition) { if (!condition) return array.length; var fn = angular['Function']['compile'](condition), count = 0; - foreach(array, function(value){ + forEach(array, function(value){ if (fn(value)) { count ++; } @@ -747,7 +747,7 @@ var angularFunction = { function defineApi(dst, chain){ angular[dst] = angular[dst] || {}; - foreach(chain, function(parent){ + forEach(chain, function(parent){ extend(angular[dst], parent); }); } diff --git a/src/directives.js b/src/directives.js index bf215cc8..8584df8b 100644 --- a/src/directives.js +++ b/src/directives.js @@ -222,7 +222,7 @@ function compileBindTemplate(template){ var fn = bindTemplateCache[template]; if (!fn) { var bindings = []; - foreach(parseBindings(template), function(text){ + forEach(parseBindings(template), function(text){ var exp = binding(text); bindings.push(exp ? function(element){ var error, value = this.$tryEval(exp, function(e){ diff --git a/src/filters.js b/src/filters.js index 9b46460d..045ad61b 100644 --- a/src/filters.js +++ b/src/filters.js @@ -222,7 +222,7 @@ angularFilter.date = function(date, format) { parts = concat(parts, DATE_FORMATS_SPLIT.exec(format), 1); format = parts.pop(); } - foreach(parts, function(value){ + forEach(parts, function(value){ fn = DATE_FORMATS[value]; text += fn ? fn(date) : value; }); diff --git a/src/formatters.js b/src/formatters.js index 46d9b817..19b8df81 100644 --- a/src/formatters.js +++ b/src/formatters.js @@ -117,7 +117,7 @@ angularFormatter.list = formatter( function(obj) { return obj ? obj.join(", ") : obj; }, function(value) { var list = []; - foreach((value || '').split(','), function(item){ + forEach((value || '').split(','), function(item){ item = trim(item); if (item) list.push(item); }); diff --git a/src/jqLite.js b/src/jqLite.js index cbb2c7b8..a59ba6c2 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -18,7 +18,7 @@ function jqClearData(element) { var cacheId = element[jqName], cache = jqCache[cacheId]; if (cache) { - foreach(cache.bind || {}, function(fn, type){ + forEach(cache.bind || {}, function(fn, type){ removeEventListenerFn(element, type, fn); }); delete jqCache[cacheId]; @@ -106,7 +106,7 @@ JQLite.prototype = { bind = self.data('bind'), eventHandler; if (!bind) this.data('bind', bind = {}); - foreach(type.split(' '), function(type){ + forEach(type.split(' '), function(type){ eventHandler = bind[type]; if (!eventHandler) { bind[type] = eventHandler = function(event) { @@ -120,7 +120,7 @@ JQLite.prototype = { event.cancelBubble = true; //ie }; } - foreach(eventHandler.fns, function(fn){ + forEach(eventHandler.fns, function(fn){ fn.call(self, event); }); }; @@ -142,7 +142,7 @@ JQLite.prototype = { append: function(node) { var self = this[0]; node = jqLite(node); - foreach(node, function(child){ + forEach(node, function(child){ self.appendChild(child); }); }, @@ -200,7 +200,7 @@ JQLite.prototype = { attr: function(name, value){ var e = this[0]; if (isObject(name)) { - foreach(name, function(value, name){ + forEach(name, function(value, name){ e.setAttribute(name, value); }); } else if (isDefined(value)) { diff --git a/src/markups.js b/src/markups.js index 454f22c2..16ca9ba8 100644 --- a/src/markups.js +++ b/src/markups.js @@ -35,7 +35,7 @@ angularTextMarkup('{{}}', function(text, textNode, parentElement) { parentElement.attr('ng:bind-template', text); } else { var cursor = textNode, newElement; - foreach(parseBindings(text), function(text){ + forEach(parseBindings(text), function(text){ var exp = binding(text); if (exp) { newElement = self.element('span'); diff --git a/src/sanitizer.js b/src/sanitizer.js index b4764271..5e99ec71 100644 --- a/src/sanitizer.js +++ b/src/sanitizer.js @@ -252,7 +252,7 @@ function htmlSanitizeWriter(buf){ if (!ignore && validElements[tag] == true) { out('<'); out(tag); - foreach(attrs, function(value, key){ + forEach(attrs, function(value, key){ var lkey=lowercase(key); if (validAttrs[lkey]==true && (uriAttrs[lkey]!==true || value.match(URI_REGEXP))) { out(' '); diff --git a/src/scenario/Describe.js b/src/scenario/Describe.js index 69ed8238..50cfded6 100644 --- a/src/scenario/Describe.js +++ b/src/scenario/Describe.js @@ -21,7 +21,7 @@ angular.scenario.Describe = function(descName, parent) { var beforeEachFns = this.beforeEachFns; this.setupBefore = function() { if (parent) parent.setupBefore.call(this); - angular.foreach(beforeEachFns, function(fn) { fn.call(this); }, this); + angular.forEach(beforeEachFns, function(fn) { fn.call(this); }, this); }; /** @@ -29,7 +29,7 @@ angular.scenario.Describe = function(descName, parent) { */ var afterEachFns = this.afterEachFns; this.setupAfter = function() { - angular.foreach(afterEachFns, function(fn) { fn.call(this); }, this); + angular.forEach(afterEachFns, function(fn) { fn.call(this); }, this); if (parent) parent.setupAfter.call(this); }; }; @@ -133,14 +133,14 @@ angular.scenario.Describe.prototype.xit = angular.noop; */ angular.scenario.Describe.prototype.getSpecs = function() { var specs = arguments[0] || []; - angular.foreach(this.children, function(child) { + angular.forEach(this.children, function(child) { child.getSpecs(specs); }); - angular.foreach(this.its, function(it) { + angular.forEach(this.its, function(it) { specs.push(it); }); var only = []; - angular.foreach(specs, function(it) { + angular.forEach(specs, function(it) { if (it.only) { only.push(it); } diff --git a/src/scenario/ObjectModel.js b/src/scenario/ObjectModel.js index e9125e03..263aa5f9 100644 --- a/src/scenario/ObjectModel.js +++ b/src/scenario/ObjectModel.js @@ -19,7 +19,7 @@ angular.scenario.ObjectModel = function(runner) { runner.on('SpecBegin', function(spec) { var block = self.value; - angular.foreach(self.getDefinitionPath(spec), function(def) { + angular.forEach(self.getDefinitionPath(spec), function(def) { if (!block.children[def.name]) { block.children[def.name] = { id: def.id, diff --git a/src/scenario/Runner.js b/src/scenario/Runner.js index f628eb04..583c8beb 100644 --- a/src/scenario/Runner.js +++ b/src/scenario/Runner.js @@ -16,7 +16,7 @@ angular.scenario.Runner = function($window) { beforeEach: this.beforeEach, afterEach: this.afterEach }; - angular.foreach(this.api, angular.bind(this, function(fn, key) { + angular.forEach(this.api, angular.bind(this, function(fn, key) { this.$window[key] = angular.bind(this, fn); })); }; @@ -33,7 +33,7 @@ angular.scenario.Runner.prototype.emit = function(eventName) { eventName = eventName.toLowerCase(); if (!this.listeners[eventName]) return; - angular.foreach(this.listeners[eventName], function(listener) { + angular.forEach(this.listeners[eventName], function(listener) { listener.apply(self, args); }); }; @@ -164,17 +164,17 @@ angular.scenario.Runner.prototype.run = function(application) { asyncForEach(this.rootDescribe.getSpecs(), function(spec, specDone) { var dslCache = {}; var runner = self.createSpecRunner_($root); - angular.foreach(angular.scenario.dsl, function(fn, key) { + angular.forEach(angular.scenario.dsl, function(fn, key) { dslCache[key] = fn.call($root); }); - angular.foreach(angular.scenario.dsl, function(fn, key) { + angular.forEach(angular.scenario.dsl, function(fn, key) { self.$window[key] = function() { var line = callerFile(3); var scope = angular.scope(runner); // Make the dsl accessible on the current chain scope.dsl = {}; - angular.foreach(dslCache, function(fn, key) { + angular.forEach(dslCache, function(fn, key) { scope.dsl[key] = function() { return dslCache[key].apply(scope, arguments); }; diff --git a/src/scenario/Scenario.js b/src/scenario/Scenario.js index a2926b5b..d1f1eb33 100644 --- a/src/scenario/Scenario.js +++ b/src/scenario/Scenario.js @@ -38,7 +38,7 @@ angular.scenario.dsl = angular.scenario.dsl || function(name, fn) { return result; var self = this; var chain = angular.extend({}, result); - angular.foreach(chain, function(value, name) { + angular.forEach(chain, function(value, name) { if (angular.isFunction(value)) { chain[name] = function() { return executeStatement.call(self, value, arguments); @@ -101,7 +101,7 @@ function angularScenarioInit($scenario, config) { output = config.scenario_output.split(','); } - angular.foreach(angular.scenario.output, function(fn, name) { + angular.forEach(angular.scenario.output, function(fn, name) { if (!output.length || indexOf(output,name) != -1) { var context = body.append('<div></div>').find('div:last'); context.attr('id', name); diff --git a/src/scenario/SpecRunner.js b/src/scenario/SpecRunner.js index f3bbe2e6..0e068f95 100644 --- a/src/scenario/SpecRunner.js +++ b/src/scenario/SpecRunner.js @@ -112,7 +112,7 @@ angular.scenario.SpecRunner.prototype.addFutureAction = function(name, behavior, var args = Array.prototype.slice.call(arguments, 1); selector = (self.selector || '') + ' ' + (selector || ''); selector = _jQuery.trim(selector) || '*'; - angular.foreach(args, function(value, index) { + angular.forEach(args, function(value, index) { selector = selector.replace('$' + (index + 1), value); }); var result = $document.find(selector); diff --git a/src/scenario/dsl.js b/src/scenario/dsl.js index 2ba61a52..4f967772 100644 --- a/src/scenario/dsl.js +++ b/src/scenario/dsl.js @@ -331,7 +331,7 @@ angular.scenario.dsl('element', function() { }); }; - angular.foreach(KEY_VALUE_METHODS, function(methodName) { + angular.forEach(KEY_VALUE_METHODS, function(methodName) { chain[methodName] = function(name, value) { var futureName = "element '" + this.label + "' get " + methodName + " '" + name + "'"; if (angular.isDefined(value)) { @@ -344,7 +344,7 @@ angular.scenario.dsl('element', function() { }; }); - angular.foreach(VALUE_METHODS, function(methodName) { + angular.forEach(VALUE_METHODS, function(methodName) { chain[methodName] = function(value) { var futureName = "element '" + this.label + "' " + methodName; if (angular.isDefined(value)) { diff --git a/src/scenario/output/Html.js b/src/scenario/output/Html.js index 4a682b9a..6e2e20f3 100644 --- a/src/scenario/output/Html.js +++ b/src/scenario/output/Html.js @@ -121,7 +121,7 @@ angular.scenario.output('html', function(context, runner) { */ function findContext(spec) { var currentContext = context.find('#specs'); - angular.foreach(model.getDefinitionPath(spec), function(defn) { + angular.forEach(model.getDefinitionPath(spec), function(defn) { var id = 'describe-' + defn.id; if (!context.find('#' + id).length) { currentContext.find('> .test-children').append( diff --git a/src/scenario/output/Xml.js b/src/scenario/output/Xml.js index cbc55ee7..e8c7f0e3 100644 --- a/src/scenario/output/Xml.js +++ b/src/scenario/output/Xml.js @@ -17,7 +17,7 @@ angular.scenario.output('xml', function(context, runner) { * @param {Object} tree node to serialize */ function serializeXml(context, tree) { - angular.foreach(tree.children, function(child) { + angular.forEach(tree.children, function(child) { var describeContext = $('<describe></describe>'); describeContext.attr('id', child.id); describeContext.attr('name', child.name); @@ -26,14 +26,14 @@ angular.scenario.output('xml', function(context, runner) { }); var its = $('<its></its>'); context.append(its); - angular.foreach(tree.specs, function(spec) { + angular.forEach(tree.specs, function(spec) { var it = $('<it></it>'); it.attr('id', spec.id); it.attr('name', spec.name); it.attr('duration', spec.duration); it.attr('status', spec.status); its.append(it); - angular.foreach(spec.steps, function(step) { + angular.forEach(spec.steps, function(step) { var stepContext = $('<step></step>'); stepContext.attr('name', step.name); stepContext.attr('duration', step.duration); diff --git a/src/services.js b/src/services.js index 42d0622f..2e5c1893 100644 --- a/src/services.js +++ b/src/services.js @@ -369,7 +369,7 @@ angularServiceInject("$log", function($window){ if (logFn.apply) { return function(){ var args = []; - foreach(arguments, function(arg){ + forEach(arguments, function(arg){ args.push(formatError(arg)); }); return logFn.apply(console, args); @@ -556,7 +556,7 @@ angularServiceInject("$invalidWidgets", function(){ /** Return count of all invalid widgets that are currently visible */ invalidWidgets.visible = function() { var count = 0; - foreach(invalidWidgets, function(widget){ + forEach(invalidWidgets, function(widget){ count = count + (isVisible(widget) ? 1 : 0); }); return count; @@ -596,7 +596,7 @@ function switchRouteMatcher(on, when, dstName) { var regex = '^' + when.replace(/[\.\\\(\)\^\$]/g, "\$1") + '$', params = [], dst = {}; - foreach(when.split(/\W/), function(param){ + forEach(when.split(/\W/), function(param){ if (param) { var paramRegExp = new RegExp(":" + param + "([\\W])"); if (regex.match(paramRegExp)) { @@ -607,7 +607,7 @@ function switchRouteMatcher(on, when, dstName) { }); var match = on.match(new RegExp(regex)); if (match) { - foreach(params, function(name, index){ + forEach(params, function(name, index){ dst[name] = match[index + 1]; }); if (dstName) this.$set(dstName, dst); @@ -716,7 +716,7 @@ angularServiceInject('$route', function(location) { function updateRoute(){ var childScope; $route.current = _null; - angular.foreach(routes, function(routeParams, route) { + angular.forEach(routes, function(routeParams, route) { if (!childScope) { var pathParams = matcher(location.hashPath, route); if (pathParams) { @@ -728,7 +728,7 @@ angularServiceInject('$route', function(location) { } } }); - angular.foreach(onChange, parentScope.$tryEval); + angular.forEach(onChange, parentScope.$tryEval); if (childScope) { childScope.$become($route.current.controller); } @@ -817,7 +817,7 @@ angularServiceInject('$xhr.bulk', function($xhr, $error, $log){ post = _null; } var currentQueue; - foreach(bulkXHR.urls, function(queue){ + forEach(bulkXHR.urls, function(queue){ if (isFunction(queue.match) ? queue.match(url) : queue.match.exec(url)) { currentQueue = queue; } @@ -831,13 +831,13 @@ angularServiceInject('$xhr.bulk', function($xhr, $error, $log){ } bulkXHR.urls = {}; bulkXHR.flush = function(callback){ - foreach(bulkXHR.urls, function(queue, url){ + forEach(bulkXHR.urls, function(queue, url){ var currentRequests = queue.requests; if (currentRequests && currentRequests.length) { queue.requests = []; queue.callbacks = []; $xhr('POST', url, {requests:currentRequests}, function(code, response){ - foreach(response, function(response, i){ + forEach(response, function(response, i){ try { if (response.status == 200) { (currentRequests[i].callback || noop)(response.status, response.response); @@ -926,7 +926,7 @@ angularServiceInject('$xhr.cache', function($xhr, $defer){ cache.data[url] = { value: response }; var callbacks = inflight[url].callbacks; delete inflight[url]; - foreach(callbacks, function(callback){ + forEach(callbacks, function(callback){ try { (callback||noop)(status, copy(response)); } catch(e) { diff --git a/src/widgets.js b/src/widgets.js index 5ff4a28f..5f159990 100644 --- a/src/widgets.js +++ b/src/widgets.js @@ -359,15 +359,15 @@ function optionsAccessor(scope, element) { return { get: function(){ var values = []; - foreach(options, function(option){ + forEach(options, function(option){ if (option.selected) values.push(option.value); }); return values; }, set: function(values){ var keys = {}; - foreach(values, function(value){ keys[value] = true; }); - foreach(options, function(option){ + forEach(values, function(value){ keys[value] = true; }); + forEach(options, function(option){ option.selected = keys[option.value]; }); } @@ -698,7 +698,7 @@ var ngSwitch = angularWidget('ng:switch', function (element){ if (isString(when)) { switchCase.when = function(scope, value){ var args = [value, when]; - foreach(usingExprParams, function(arg){ + forEach(usingExprParams, function(arg){ args.push(arg); }); return usingFn.apply(scope, args); @@ -711,7 +711,7 @@ var ngSwitch = angularWidget('ng:switch', function (element){ }); // this needs to be here for IE - foreach(cases, function(_case){ + forEach(cases, function(_case){ _case.element.remove(); }); @@ -722,7 +722,7 @@ var ngSwitch = angularWidget('ng:switch', function (element){ var found = false; element.html(''); childScope = createScope(scope); - foreach(cases, function(switchCase){ + forEach(cases, function(switchCase){ if (!found && switchCase.when(childScope, value)) { found = true; var caseElement = quickClone(switchCase.element); 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); }); |
