mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
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
This commit is contained in:
parent
c79aba92f6
commit
0a6cf70deb
32 changed files with 101 additions and 96 deletions
|
|
@ -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) #
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ var _undefined = undefined,
|
|||
/**
|
||||
* @workInProgress
|
||||
* @ngdoc function
|
||||
* @name angular.foreach
|
||||
* @name angular.forEach
|
||||
* @function
|
||||
*
|
||||
* @description
|
||||
|
|
@ -123,11 +123,13 @@ var _undefined = undefined,
|
|||
* be an object or an array. The `iterator` function is invoked with `iterator(value, key)`, where
|
||||
* `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('&') : '';
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ extend(angular, {
|
|||
'copy': copy,
|
||||
'extend': extend,
|
||||
'equals': equals,
|
||||
'foreach': foreach,
|
||||
'forEach': forEach,
|
||||
'injector': createInjector,
|
||||
'noop':noop,
|
||||
'bind':bind,
|
||||
|
|
|
|||
|
|
@ -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(); });
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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){
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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(' ');
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ describe('browser', function(){
|
|||
}
|
||||
|
||||
fakeSetTimeout.flush = function() {
|
||||
foreach(setTimeoutQueue, function(fn) {
|
||||
forEach(setTimeoutQueue, function(fn) {
|
||||
fn();
|
||||
});
|
||||
};
|
||||
|
|
|
|||
4
test/angular-mocks.js
vendored
4
test/angular-mocks.js
vendored
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue