mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-18 07:50: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`
|
- 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.
|
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) #
|
# <angular/> 0.9.8 astral-projection (2010-12-23) #
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ var _undefined = undefined,
|
||||||
/**
|
/**
|
||||||
* @workInProgress
|
* @workInProgress
|
||||||
* @ngdoc function
|
* @ngdoc function
|
||||||
* @name angular.foreach
|
* @name angular.forEach
|
||||||
* @function
|
* @function
|
||||||
*
|
*
|
||||||
* @description
|
* @description
|
||||||
|
|
@ -123,11 +123,13 @@ var _undefined = undefined,
|
||||||
* be an object or an array. The `iterator` function is invoked with `iterator(value, key)`, where
|
* 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
|
* `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.
|
* key or array element index. Optionally, `context` can be specified for the iterator function.
|
||||||
|
*
|
||||||
|
* Note: this function was previously known as `angular.foreach`.
|
||||||
*
|
*
|
||||||
<pre>
|
<pre>
|
||||||
var values = {name: 'misko', gender: 'male'};
|
var values = {name: 'misko', gender: 'male'};
|
||||||
var log = [];
|
var log = [];
|
||||||
angular.foreach(values, function(value, key){
|
angular.forEach(values, function(value, key){
|
||||||
this.push(key + ': ' + value);
|
this.push(key + ': ' + value);
|
||||||
}, log);
|
}, log);
|
||||||
expect(log).toEqual(['name: misko', 'gender:male']);
|
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.
|
* @param {Object} context Object to become context (`this`) for the iterator function.
|
||||||
* @returns {Objet|Array} Reference to `obj`.
|
* @returns {Objet|Array} Reference to `obj`.
|
||||||
*/
|
*/
|
||||||
function foreach(obj, iterator, context) {
|
function forEach(obj, iterator, context) {
|
||||||
var key;
|
var key;
|
||||||
if (obj) {
|
if (obj) {
|
||||||
if (isFunction(obj)){
|
if (isFunction(obj)){
|
||||||
|
|
@ -147,7 +149,7 @@ function foreach(obj, iterator, context) {
|
||||||
iterator.call(context, obj[key], key);
|
iterator.call(context, obj[key], key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (obj.forEach) {
|
} else if (obj.forEach && obj.forEach !== forEach) {
|
||||||
obj.forEach(iterator, context);
|
obj.forEach(iterator, context);
|
||||||
} else if (isObject(obj) && isNumber(obj.length)) {
|
} else if (isObject(obj) && isNumber(obj.length)) {
|
||||||
for (key = 0; key < obj.length; key++)
|
for (key = 0; key < obj.length; key++)
|
||||||
|
|
@ -160,7 +162,7 @@ function foreach(obj, iterator, context) {
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
function foreachSorted(obj, iterator, context) {
|
function forEachSorted(obj, iterator, context) {
|
||||||
var keys = [];
|
var keys = [];
|
||||||
for (var key in obj) keys.push(key);
|
for (var key in obj) keys.push(key);
|
||||||
keys.sort();
|
keys.sort();
|
||||||
|
|
@ -197,9 +199,9 @@ function formatError(arg) {
|
||||||
* @param {...Object} src The source object(s).
|
* @param {...Object} src The source object(s).
|
||||||
*/
|
*/
|
||||||
function extend(dst) {
|
function extend(dst) {
|
||||||
foreach(arguments, function(obj){
|
forEach(arguments, function(obj){
|
||||||
if (obj !== dst) {
|
if (obj !== dst) {
|
||||||
foreach(obj, function(value, key){
|
forEach(obj, function(value, key){
|
||||||
dst[key] = value;
|
dst[key] = value;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -459,7 +461,7 @@ function isVisible(element) {
|
||||||
|
|
||||||
function map(obj, iterator, context) {
|
function map(obj, iterator, context) {
|
||||||
var results = [];
|
var results = [];
|
||||||
foreach(obj, function(value, index, list) {
|
forEach(obj, function(value, index, list) {
|
||||||
results.push(iterator.call(context, value, index, list));
|
results.push(iterator.call(context, value, index, list));
|
||||||
});
|
});
|
||||||
return results;
|
return results;
|
||||||
|
|
@ -580,7 +582,7 @@ function copy(source, destination){
|
||||||
destination.push(copy(source[i]));
|
destination.push(copy(source[i]));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach(destination, function(value, key){
|
forEach(destination, function(value, key){
|
||||||
delete destination[key];
|
delete destination[key];
|
||||||
});
|
});
|
||||||
for ( var key in source) {
|
for ( var key in source) {
|
||||||
|
|
@ -778,7 +780,7 @@ function compile(element, parentScope) {
|
||||||
*/
|
*/
|
||||||
function parseKeyValue(/**string*/keyValue) {
|
function parseKeyValue(/**string*/keyValue) {
|
||||||
var obj = {}, key_value, key;
|
var obj = {}, key_value, key;
|
||||||
foreach((keyValue || "").split('&'), function(keyValue){
|
forEach((keyValue || "").split('&'), function(keyValue){
|
||||||
if (keyValue) {
|
if (keyValue) {
|
||||||
key_value = keyValue.split('=');
|
key_value = keyValue.split('=');
|
||||||
key = unescape(key_value[0]);
|
key = unescape(key_value[0]);
|
||||||
|
|
@ -790,7 +792,7 @@ function parseKeyValue(/**string*/keyValue) {
|
||||||
|
|
||||||
function toKeyValue(obj) {
|
function toKeyValue(obj) {
|
||||||
var parts = [];
|
var parts = [];
|
||||||
foreach(obj, function(value, key) {
|
forEach(obj, function(value, key) {
|
||||||
parts.push(escape(key) + (value === true ? '' : '=' + escape(value)));
|
parts.push(escape(key) + (value === true ? '' : '=' + escape(value)));
|
||||||
});
|
});
|
||||||
return parts.length ? parts.join('&') : '';
|
return parts.length ? parts.join('&') : '';
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ extend(angular, {
|
||||||
'copy': copy,
|
'copy': copy,
|
||||||
'extend': extend,
|
'extend': extend,
|
||||||
'equals': equals,
|
'equals': equals,
|
||||||
'foreach': foreach,
|
'forEach': forEach,
|
||||||
'injector': createInjector,
|
'injector': createInjector,
|
||||||
'noop':noop,
|
'noop':noop,
|
||||||
'bind':bind,
|
'bind':bind,
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ function Browser(window, document, body, XHR, $log) {
|
||||||
* @methodOf angular.service.$browser
|
* @methodOf angular.service.$browser
|
||||||
*/
|
*/
|
||||||
self.poll = function() {
|
self.poll = function() {
|
||||||
foreach(pollFns, function(pollFn){ pollFn(); });
|
forEach(pollFns, function(pollFn){ pollFn(); });
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@ Template.prototype = {
|
||||||
init: function(element, scope) {
|
init: function(element, scope) {
|
||||||
var inits = {};
|
var inits = {};
|
||||||
this.collectInits(element, inits, scope);
|
this.collectInits(element, inits, scope);
|
||||||
foreachSorted(inits, function(queue){
|
forEachSorted(inits, function(queue){
|
||||||
foreach(queue, function(fn) {fn();});
|
forEach(queue, function(fn) {fn();});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -32,7 +32,7 @@ Template.prototype = {
|
||||||
scope.$onEval(childScope.$eval);
|
scope.$onEval(childScope.$eval);
|
||||||
element.data($$scope, childScope);
|
element.data($$scope, childScope);
|
||||||
}
|
}
|
||||||
foreach(this.inits, function(fn) {
|
forEach(this.inits, function(fn) {
|
||||||
queue.push(function() {
|
queue.push(function() {
|
||||||
childScope.$tryEval(function(){
|
childScope.$tryEval(function(){
|
||||||
return childScope.$service(fn, childScope, element);
|
return childScope.$service(fn, childScope, element);
|
||||||
|
|
@ -232,7 +232,7 @@ Compiler.prototype = {
|
||||||
for(var i=0, child=element[0].childNodes;
|
for(var i=0, child=element[0].childNodes;
|
||||||
i<child.length; i++) {
|
i<child.length; i++) {
|
||||||
if (isTextNode(child[i])) {
|
if (isTextNode(child[i])) {
|
||||||
foreach(self.markup, function(markup){
|
forEach(self.markup, function(markup){
|
||||||
if (i<child.length) {
|
if (i<child.length) {
|
||||||
var textNode = jqLite(child[i]);
|
var textNode = jqLite(child[i]);
|
||||||
markup.call(selfApi, textNode.text(), textNode, element);
|
markup.call(selfApi, textNode.text(), textNode, element);
|
||||||
|
|
@ -245,7 +245,7 @@ Compiler.prototype = {
|
||||||
if (directives) {
|
if (directives) {
|
||||||
// Process attributes/directives
|
// Process attributes/directives
|
||||||
eachAttribute(element, function(value, name){
|
eachAttribute(element, function(value, name){
|
||||||
foreach(self.attrMarkup, function(markup){
|
forEach(self.attrMarkup, function(markup){
|
||||||
markup.call(selfApi, value, name, element);
|
markup.call(selfApi, value, name, element);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -287,6 +287,6 @@ function eachAttribute(element, fn){
|
||||||
}
|
}
|
||||||
attrValue[name] = value;
|
attrValue[name] = value;
|
||||||
}
|
}
|
||||||
foreachSorted(attrValue, fn);
|
forEachSorted(attrValue, fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,14 +47,14 @@ function createInjector(providerScope, providers, cache) {
|
||||||
returnValue = cache[value];
|
returnValue = cache[value];
|
||||||
} else if (isArray(value)) {
|
} else if (isArray(value)) {
|
||||||
returnValue = [];
|
returnValue = [];
|
||||||
foreach(value, function(name) {
|
forEach(value, function(name) {
|
||||||
returnValue.push(inject(name));
|
returnValue.push(inject(name));
|
||||||
});
|
});
|
||||||
} else if (isFunction(value)) {
|
} else if (isFunction(value)) {
|
||||||
returnValue = inject(value.$inject || []);
|
returnValue = inject(value.$inject || []);
|
||||||
returnValue = value.apply(scope, concat(returnValue, arguments, 2));
|
returnValue = value.apply(scope, concat(returnValue, arguments, 2));
|
||||||
} else if (isObject(value)) {
|
} else if (isObject(value)) {
|
||||||
foreach(providers, function(provider, name){
|
forEach(providers, function(provider, name){
|
||||||
if (provider.$eager)
|
if (provider.$eager)
|
||||||
inject(name);
|
inject(name);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,12 +53,12 @@ function fromJson(json, useNative) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO make foreach optionally recursive and remove this function
|
// TODO make forEach optionally recursive and remove this function
|
||||||
function transformDates(obj) {
|
function transformDates(obj) {
|
||||||
if (isString(obj) && obj.length === DATE_ISOSTRING_LN) {
|
if (isString(obj) && obj.length === DATE_ISOSTRING_LN) {
|
||||||
return angularString.toDate(obj);
|
return angularString.toDate(obj);
|
||||||
} else if (isArray(obj) || isObject(obj)) {
|
} else if (isArray(obj) || isObject(obj)) {
|
||||||
foreach(obj, function(val, name) {
|
forEach(obj, function(val, name) {
|
||||||
obj[name] = transformDates(val);
|
obj[name] = transformDates(val);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ function Route(template, defaults) {
|
||||||
this.template = template = template + '#';
|
this.template = template = template + '#';
|
||||||
this.defaults = defaults || {};
|
this.defaults = defaults || {};
|
||||||
var urlParams = this.urlParams = {};
|
var urlParams = this.urlParams = {};
|
||||||
foreach(template.split(/\W/), function(param){
|
forEach(template.split(/\W/), function(param){
|
||||||
if (param && template.match(new RegExp(":" + param + "\\W"))) {
|
if (param && template.match(new RegExp(":" + param + "\\W"))) {
|
||||||
urlParams[param] = true;
|
urlParams[param] = true;
|
||||||
}
|
}
|
||||||
|
|
@ -17,13 +17,13 @@ Route.prototype = {
|
||||||
var self = this;
|
var self = this;
|
||||||
var url = this.template;
|
var url = this.template;
|
||||||
params = params || {};
|
params = params || {};
|
||||||
foreach(this.urlParams, function(_, urlParam){
|
forEach(this.urlParams, function(_, urlParam){
|
||||||
var value = params[urlParam] || self.defaults[urlParam] || "";
|
var value = params[urlParam] || self.defaults[urlParam] || "";
|
||||||
url = url.replace(new RegExp(":" + urlParam + "(\\W)"), value + "$1");
|
url = url.replace(new RegExp(":" + urlParam + "(\\W)"), value + "$1");
|
||||||
});
|
});
|
||||||
url = url.replace(/\/?#$/, '');
|
url = url.replace(/\/?#$/, '');
|
||||||
var query = [];
|
var query = [];
|
||||||
foreachSorted(params, function(value, key){
|
forEachSorted(params, function(value, key){
|
||||||
if (!self.urlParams[key]) {
|
if (!self.urlParams[key]) {
|
||||||
query.push(encodeURI(key) + '=' + encodeURI(value));
|
query.push(encodeURI(key) + '=' + encodeURI(value));
|
||||||
}
|
}
|
||||||
|
|
@ -52,7 +52,7 @@ ResourceFactory.prototype = {
|
||||||
actions = extend({}, ResourceFactory.DEFAULT_ACTIONS, actions);
|
actions = extend({}, ResourceFactory.DEFAULT_ACTIONS, actions);
|
||||||
function extractParams(data){
|
function extractParams(data){
|
||||||
var ids = {};
|
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;
|
ids[key] = value.charAt && value.charAt(0) == '@' ? getter(data, value.substr(1)) : value;
|
||||||
});
|
});
|
||||||
return ids;
|
return ids;
|
||||||
|
|
@ -62,7 +62,7 @@ ResourceFactory.prototype = {
|
||||||
copy(value || {}, this);
|
copy(value || {}, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(actions, function(action, name){
|
forEach(actions, function(action, name){
|
||||||
var isPostOrPut = action.method == 'POST' || action.method == 'PUT';
|
var isPostOrPut = action.method == 'POST' || action.method == 'PUT';
|
||||||
Resource[name] = function (a1, a2, a3) {
|
Resource[name] = function (a1, a2, a3) {
|
||||||
var params = {};
|
var params = {};
|
||||||
|
|
@ -97,7 +97,7 @@ ResourceFactory.prototype = {
|
||||||
if (status == 200) {
|
if (status == 200) {
|
||||||
if (action.isArray) {
|
if (action.isArray) {
|
||||||
value.length = 0;
|
value.length = 0;
|
||||||
foreach(response, function(item){
|
forEach(response, function(item){
|
||||||
value.push(new Resource(item));
|
value.push(new Resource(item));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ var scopeId = 0,
|
||||||
getterFnCache = {},
|
getterFnCache = {},
|
||||||
compileCache = {},
|
compileCache = {},
|
||||||
JS_KEYWORDS = {};
|
JS_KEYWORDS = {};
|
||||||
foreach(
|
forEach(
|
||||||
("abstract,boolean,break,byte,case,catch,char,class,const,continue,debugger,default," +
|
("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," +
|
"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," +
|
"if,implements,import,ininstanceof,intinterface,long,native,new,null,package,private," +
|
||||||
|
|
@ -61,7 +61,7 @@ function getterFn(path){
|
||||||
if (fn) return fn;
|
if (fn) return fn;
|
||||||
|
|
||||||
var code = 'var l, fn, t;\n';
|
var code = 'var l, fn, t;\n';
|
||||||
foreach(path.split('.'), function(key) {
|
forEach(path.split('.'), function(key) {
|
||||||
key = (JS_KEYWORDS[key]) ? '["' + key + '"]' : '.' + key;
|
key = (JS_KEYWORDS[key]) ? '["' + key + '"]' : '.' + key;
|
||||||
code += 'if(!s) return s;\n' +
|
code += 'if(!s) return s;\n' +
|
||||||
'l=s;\n' +
|
'l=s;\n' +
|
||||||
|
|
@ -575,7 +575,7 @@ function createScope(parent, providers, instanceCache) {
|
||||||
$become: function(Class) {
|
$become: function(Class) {
|
||||||
if (isFunction(Class)) {
|
if (isFunction(Class)) {
|
||||||
instance.constructor = Class;
|
instance.constructor = Class;
|
||||||
foreach(Class.prototype, function(fn, name){
|
forEach(Class.prototype, function(fn, name){
|
||||||
instance[name] = bind(instance, fn);
|
instance[name] = bind(instance, fn);
|
||||||
});
|
});
|
||||||
instance.$service.apply(instance, concat([Class, instance], arguments, 1));
|
instance.$service.apply(instance, concat([Class, instance], arguments, 1));
|
||||||
|
|
|
||||||
|
|
@ -499,7 +499,7 @@ var angularArray = {
|
||||||
'count':function(array, condition) {
|
'count':function(array, condition) {
|
||||||
if (!condition) return array.length;
|
if (!condition) return array.length;
|
||||||
var fn = angular['Function']['compile'](condition), count = 0;
|
var fn = angular['Function']['compile'](condition), count = 0;
|
||||||
foreach(array, function(value){
|
forEach(array, function(value){
|
||||||
if (fn(value)) {
|
if (fn(value)) {
|
||||||
count ++;
|
count ++;
|
||||||
}
|
}
|
||||||
|
|
@ -747,7 +747,7 @@ var angularFunction = {
|
||||||
|
|
||||||
function defineApi(dst, chain){
|
function defineApi(dst, chain){
|
||||||
angular[dst] = angular[dst] || {};
|
angular[dst] = angular[dst] || {};
|
||||||
foreach(chain, function(parent){
|
forEach(chain, function(parent){
|
||||||
extend(angular[dst], parent);
|
extend(angular[dst], parent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -222,7 +222,7 @@ function compileBindTemplate(template){
|
||||||
var fn = bindTemplateCache[template];
|
var fn = bindTemplateCache[template];
|
||||||
if (!fn) {
|
if (!fn) {
|
||||||
var bindings = [];
|
var bindings = [];
|
||||||
foreach(parseBindings(template), function(text){
|
forEach(parseBindings(template), function(text){
|
||||||
var exp = binding(text);
|
var exp = binding(text);
|
||||||
bindings.push(exp ? function(element){
|
bindings.push(exp ? function(element){
|
||||||
var error, value = this.$tryEval(exp, function(e){
|
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);
|
parts = concat(parts, DATE_FORMATS_SPLIT.exec(format), 1);
|
||||||
format = parts.pop();
|
format = parts.pop();
|
||||||
}
|
}
|
||||||
foreach(parts, function(value){
|
forEach(parts, function(value){
|
||||||
fn = DATE_FORMATS[value];
|
fn = DATE_FORMATS[value];
|
||||||
text += fn ? fn(date) : value;
|
text += fn ? fn(date) : value;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ angularFormatter.list = formatter(
|
||||||
function(obj) { return obj ? obj.join(", ") : obj; },
|
function(obj) { return obj ? obj.join(", ") : obj; },
|
||||||
function(value) {
|
function(value) {
|
||||||
var list = [];
|
var list = [];
|
||||||
foreach((value || '').split(','), function(item){
|
forEach((value || '').split(','), function(item){
|
||||||
item = trim(item);
|
item = trim(item);
|
||||||
if (item) list.push(item);
|
if (item) list.push(item);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ function jqClearData(element) {
|
||||||
var cacheId = element[jqName],
|
var cacheId = element[jqName],
|
||||||
cache = jqCache[cacheId];
|
cache = jqCache[cacheId];
|
||||||
if (cache) {
|
if (cache) {
|
||||||
foreach(cache.bind || {}, function(fn, type){
|
forEach(cache.bind || {}, function(fn, type){
|
||||||
removeEventListenerFn(element, type, fn);
|
removeEventListenerFn(element, type, fn);
|
||||||
});
|
});
|
||||||
delete jqCache[cacheId];
|
delete jqCache[cacheId];
|
||||||
|
|
@ -106,7 +106,7 @@ JQLite.prototype = {
|
||||||
bind = self.data('bind'),
|
bind = self.data('bind'),
|
||||||
eventHandler;
|
eventHandler;
|
||||||
if (!bind) this.data('bind', bind = {});
|
if (!bind) this.data('bind', bind = {});
|
||||||
foreach(type.split(' '), function(type){
|
forEach(type.split(' '), function(type){
|
||||||
eventHandler = bind[type];
|
eventHandler = bind[type];
|
||||||
if (!eventHandler) {
|
if (!eventHandler) {
|
||||||
bind[type] = eventHandler = function(event) {
|
bind[type] = eventHandler = function(event) {
|
||||||
|
|
@ -120,7 +120,7 @@ JQLite.prototype = {
|
||||||
event.cancelBubble = true; //ie
|
event.cancelBubble = true; //ie
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
foreach(eventHandler.fns, function(fn){
|
forEach(eventHandler.fns, function(fn){
|
||||||
fn.call(self, event);
|
fn.call(self, event);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -142,7 +142,7 @@ JQLite.prototype = {
|
||||||
append: function(node) {
|
append: function(node) {
|
||||||
var self = this[0];
|
var self = this[0];
|
||||||
node = jqLite(node);
|
node = jqLite(node);
|
||||||
foreach(node, function(child){
|
forEach(node, function(child){
|
||||||
self.appendChild(child);
|
self.appendChild(child);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
@ -200,7 +200,7 @@ JQLite.prototype = {
|
||||||
attr: function(name, value){
|
attr: function(name, value){
|
||||||
var e = this[0];
|
var e = this[0];
|
||||||
if (isObject(name)) {
|
if (isObject(name)) {
|
||||||
foreach(name, function(value, name){
|
forEach(name, function(value, name){
|
||||||
e.setAttribute(name, value);
|
e.setAttribute(name, value);
|
||||||
});
|
});
|
||||||
} else if (isDefined(value)) {
|
} else if (isDefined(value)) {
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ angularTextMarkup('{{}}', function(text, textNode, parentElement) {
|
||||||
parentElement.attr('ng:bind-template', text);
|
parentElement.attr('ng:bind-template', text);
|
||||||
} else {
|
} else {
|
||||||
var cursor = textNode, newElement;
|
var cursor = textNode, newElement;
|
||||||
foreach(parseBindings(text), function(text){
|
forEach(parseBindings(text), function(text){
|
||||||
var exp = binding(text);
|
var exp = binding(text);
|
||||||
if (exp) {
|
if (exp) {
|
||||||
newElement = self.element('span');
|
newElement = self.element('span');
|
||||||
|
|
|
||||||
|
|
@ -252,7 +252,7 @@ function htmlSanitizeWriter(buf){
|
||||||
if (!ignore && validElements[tag] == true) {
|
if (!ignore && validElements[tag] == true) {
|
||||||
out('<');
|
out('<');
|
||||||
out(tag);
|
out(tag);
|
||||||
foreach(attrs, function(value, key){
|
forEach(attrs, function(value, key){
|
||||||
var lkey=lowercase(key);
|
var lkey=lowercase(key);
|
||||||
if (validAttrs[lkey]==true && (uriAttrs[lkey]!==true || value.match(URI_REGEXP))) {
|
if (validAttrs[lkey]==true && (uriAttrs[lkey]!==true || value.match(URI_REGEXP))) {
|
||||||
out(' ');
|
out(' ');
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ angular.scenario.Describe = function(descName, parent) {
|
||||||
var beforeEachFns = this.beforeEachFns;
|
var beforeEachFns = this.beforeEachFns;
|
||||||
this.setupBefore = function() {
|
this.setupBefore = function() {
|
||||||
if (parent) parent.setupBefore.call(this);
|
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;
|
var afterEachFns = this.afterEachFns;
|
||||||
this.setupAfter = function() {
|
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);
|
if (parent) parent.setupAfter.call(this);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -133,14 +133,14 @@ angular.scenario.Describe.prototype.xit = angular.noop;
|
||||||
*/
|
*/
|
||||||
angular.scenario.Describe.prototype.getSpecs = function() {
|
angular.scenario.Describe.prototype.getSpecs = function() {
|
||||||
var specs = arguments[0] || [];
|
var specs = arguments[0] || [];
|
||||||
angular.foreach(this.children, function(child) {
|
angular.forEach(this.children, function(child) {
|
||||||
child.getSpecs(specs);
|
child.getSpecs(specs);
|
||||||
});
|
});
|
||||||
angular.foreach(this.its, function(it) {
|
angular.forEach(this.its, function(it) {
|
||||||
specs.push(it);
|
specs.push(it);
|
||||||
});
|
});
|
||||||
var only = [];
|
var only = [];
|
||||||
angular.foreach(specs, function(it) {
|
angular.forEach(specs, function(it) {
|
||||||
if (it.only) {
|
if (it.only) {
|
||||||
only.push(it);
|
only.push(it);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ angular.scenario.ObjectModel = function(runner) {
|
||||||
|
|
||||||
runner.on('SpecBegin', function(spec) {
|
runner.on('SpecBegin', function(spec) {
|
||||||
var block = self.value;
|
var block = self.value;
|
||||||
angular.foreach(self.getDefinitionPath(spec), function(def) {
|
angular.forEach(self.getDefinitionPath(spec), function(def) {
|
||||||
if (!block.children[def.name]) {
|
if (!block.children[def.name]) {
|
||||||
block.children[def.name] = {
|
block.children[def.name] = {
|
||||||
id: def.id,
|
id: def.id,
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ angular.scenario.Runner = function($window) {
|
||||||
beforeEach: this.beforeEach,
|
beforeEach: this.beforeEach,
|
||||||
afterEach: this.afterEach
|
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);
|
this.$window[key] = angular.bind(this, fn);
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
@ -33,7 +33,7 @@ angular.scenario.Runner.prototype.emit = function(eventName) {
|
||||||
eventName = eventName.toLowerCase();
|
eventName = eventName.toLowerCase();
|
||||||
if (!this.listeners[eventName])
|
if (!this.listeners[eventName])
|
||||||
return;
|
return;
|
||||||
angular.foreach(this.listeners[eventName], function(listener) {
|
angular.forEach(this.listeners[eventName], function(listener) {
|
||||||
listener.apply(self, args);
|
listener.apply(self, args);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -164,17 +164,17 @@ angular.scenario.Runner.prototype.run = function(application) {
|
||||||
asyncForEach(this.rootDescribe.getSpecs(), function(spec, specDone) {
|
asyncForEach(this.rootDescribe.getSpecs(), function(spec, specDone) {
|
||||||
var dslCache = {};
|
var dslCache = {};
|
||||||
var runner = self.createSpecRunner_($root);
|
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);
|
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() {
|
self.$window[key] = function() {
|
||||||
var line = callerFile(3);
|
var line = callerFile(3);
|
||||||
var scope = angular.scope(runner);
|
var scope = angular.scope(runner);
|
||||||
|
|
||||||
// Make the dsl accessible on the current chain
|
// Make the dsl accessible on the current chain
|
||||||
scope.dsl = {};
|
scope.dsl = {};
|
||||||
angular.foreach(dslCache, function(fn, key) {
|
angular.forEach(dslCache, function(fn, key) {
|
||||||
scope.dsl[key] = function() {
|
scope.dsl[key] = function() {
|
||||||
return dslCache[key].apply(scope, arguments);
|
return dslCache[key].apply(scope, arguments);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ angular.scenario.dsl = angular.scenario.dsl || function(name, fn) {
|
||||||
return result;
|
return result;
|
||||||
var self = this;
|
var self = this;
|
||||||
var chain = angular.extend({}, result);
|
var chain = angular.extend({}, result);
|
||||||
angular.foreach(chain, function(value, name) {
|
angular.forEach(chain, function(value, name) {
|
||||||
if (angular.isFunction(value)) {
|
if (angular.isFunction(value)) {
|
||||||
chain[name] = function() {
|
chain[name] = function() {
|
||||||
return executeStatement.call(self, value, arguments);
|
return executeStatement.call(self, value, arguments);
|
||||||
|
|
@ -101,7 +101,7 @@ function angularScenarioInit($scenario, config) {
|
||||||
output = config.scenario_output.split(',');
|
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) {
|
if (!output.length || indexOf(output,name) != -1) {
|
||||||
var context = body.append('<div></div>').find('div:last');
|
var context = body.append('<div></div>').find('div:last');
|
||||||
context.attr('id', name);
|
context.attr('id', name);
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ angular.scenario.SpecRunner.prototype.addFutureAction = function(name, behavior,
|
||||||
var args = Array.prototype.slice.call(arguments, 1);
|
var args = Array.prototype.slice.call(arguments, 1);
|
||||||
selector = (self.selector || '') + ' ' + (selector || '');
|
selector = (self.selector || '') + ' ' + (selector || '');
|
||||||
selector = _jQuery.trim(selector) || '*';
|
selector = _jQuery.trim(selector) || '*';
|
||||||
angular.foreach(args, function(value, index) {
|
angular.forEach(args, function(value, index) {
|
||||||
selector = selector.replace('$' + (index + 1), value);
|
selector = selector.replace('$' + (index + 1), value);
|
||||||
});
|
});
|
||||||
var result = $document.find(selector);
|
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) {
|
chain[methodName] = function(name, value) {
|
||||||
var futureName = "element '" + this.label + "' get " + methodName + " '" + name + "'";
|
var futureName = "element '" + this.label + "' get " + methodName + " '" + name + "'";
|
||||||
if (angular.isDefined(value)) {
|
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) {
|
chain[methodName] = function(value) {
|
||||||
var futureName = "element '" + this.label + "' " + methodName;
|
var futureName = "element '" + this.label + "' " + methodName;
|
||||||
if (angular.isDefined(value)) {
|
if (angular.isDefined(value)) {
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ angular.scenario.output('html', function(context, runner) {
|
||||||
*/
|
*/
|
||||||
function findContext(spec) {
|
function findContext(spec) {
|
||||||
var currentContext = context.find('#specs');
|
var currentContext = context.find('#specs');
|
||||||
angular.foreach(model.getDefinitionPath(spec), function(defn) {
|
angular.forEach(model.getDefinitionPath(spec), function(defn) {
|
||||||
var id = 'describe-' + defn.id;
|
var id = 'describe-' + defn.id;
|
||||||
if (!context.find('#' + id).length) {
|
if (!context.find('#' + id).length) {
|
||||||
currentContext.find('> .test-children').append(
|
currentContext.find('> .test-children').append(
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ angular.scenario.output('xml', function(context, runner) {
|
||||||
* @param {Object} tree node to serialize
|
* @param {Object} tree node to serialize
|
||||||
*/
|
*/
|
||||||
function serializeXml(context, tree) {
|
function serializeXml(context, tree) {
|
||||||
angular.foreach(tree.children, function(child) {
|
angular.forEach(tree.children, function(child) {
|
||||||
var describeContext = $('<describe></describe>');
|
var describeContext = $('<describe></describe>');
|
||||||
describeContext.attr('id', child.id);
|
describeContext.attr('id', child.id);
|
||||||
describeContext.attr('name', child.name);
|
describeContext.attr('name', child.name);
|
||||||
|
|
@ -26,14 +26,14 @@ angular.scenario.output('xml', function(context, runner) {
|
||||||
});
|
});
|
||||||
var its = $('<its></its>');
|
var its = $('<its></its>');
|
||||||
context.append(its);
|
context.append(its);
|
||||||
angular.foreach(tree.specs, function(spec) {
|
angular.forEach(tree.specs, function(spec) {
|
||||||
var it = $('<it></it>');
|
var it = $('<it></it>');
|
||||||
it.attr('id', spec.id);
|
it.attr('id', spec.id);
|
||||||
it.attr('name', spec.name);
|
it.attr('name', spec.name);
|
||||||
it.attr('duration', spec.duration);
|
it.attr('duration', spec.duration);
|
||||||
it.attr('status', spec.status);
|
it.attr('status', spec.status);
|
||||||
its.append(it);
|
its.append(it);
|
||||||
angular.foreach(spec.steps, function(step) {
|
angular.forEach(spec.steps, function(step) {
|
||||||
var stepContext = $('<step></step>');
|
var stepContext = $('<step></step>');
|
||||||
stepContext.attr('name', step.name);
|
stepContext.attr('name', step.name);
|
||||||
stepContext.attr('duration', step.duration);
|
stepContext.attr('duration', step.duration);
|
||||||
|
|
|
||||||
|
|
@ -369,7 +369,7 @@ angularServiceInject("$log", function($window){
|
||||||
if (logFn.apply) {
|
if (logFn.apply) {
|
||||||
return function(){
|
return function(){
|
||||||
var args = [];
|
var args = [];
|
||||||
foreach(arguments, function(arg){
|
forEach(arguments, function(arg){
|
||||||
args.push(formatError(arg));
|
args.push(formatError(arg));
|
||||||
});
|
});
|
||||||
return logFn.apply(console, args);
|
return logFn.apply(console, args);
|
||||||
|
|
@ -556,7 +556,7 @@ angularServiceInject("$invalidWidgets", function(){
|
||||||
/** Return count of all invalid widgets that are currently visible */
|
/** Return count of all invalid widgets that are currently visible */
|
||||||
invalidWidgets.visible = function() {
|
invalidWidgets.visible = function() {
|
||||||
var count = 0;
|
var count = 0;
|
||||||
foreach(invalidWidgets, function(widget){
|
forEach(invalidWidgets, function(widget){
|
||||||
count = count + (isVisible(widget) ? 1 : 0);
|
count = count + (isVisible(widget) ? 1 : 0);
|
||||||
});
|
});
|
||||||
return count;
|
return count;
|
||||||
|
|
@ -596,7 +596,7 @@ function switchRouteMatcher(on, when, dstName) {
|
||||||
var regex = '^' + when.replace(/[\.\\\(\)\^\$]/g, "\$1") + '$',
|
var regex = '^' + when.replace(/[\.\\\(\)\^\$]/g, "\$1") + '$',
|
||||||
params = [],
|
params = [],
|
||||||
dst = {};
|
dst = {};
|
||||||
foreach(when.split(/\W/), function(param){
|
forEach(when.split(/\W/), function(param){
|
||||||
if (param) {
|
if (param) {
|
||||||
var paramRegExp = new RegExp(":" + param + "([\\W])");
|
var paramRegExp = new RegExp(":" + param + "([\\W])");
|
||||||
if (regex.match(paramRegExp)) {
|
if (regex.match(paramRegExp)) {
|
||||||
|
|
@ -607,7 +607,7 @@ function switchRouteMatcher(on, when, dstName) {
|
||||||
});
|
});
|
||||||
var match = on.match(new RegExp(regex));
|
var match = on.match(new RegExp(regex));
|
||||||
if (match) {
|
if (match) {
|
||||||
foreach(params, function(name, index){
|
forEach(params, function(name, index){
|
||||||
dst[name] = match[index + 1];
|
dst[name] = match[index + 1];
|
||||||
});
|
});
|
||||||
if (dstName) this.$set(dstName, dst);
|
if (dstName) this.$set(dstName, dst);
|
||||||
|
|
@ -716,7 +716,7 @@ angularServiceInject('$route', function(location) {
|
||||||
function updateRoute(){
|
function updateRoute(){
|
||||||
var childScope;
|
var childScope;
|
||||||
$route.current = _null;
|
$route.current = _null;
|
||||||
angular.foreach(routes, function(routeParams, route) {
|
angular.forEach(routes, function(routeParams, route) {
|
||||||
if (!childScope) {
|
if (!childScope) {
|
||||||
var pathParams = matcher(location.hashPath, route);
|
var pathParams = matcher(location.hashPath, route);
|
||||||
if (pathParams) {
|
if (pathParams) {
|
||||||
|
|
@ -728,7 +728,7 @@ angularServiceInject('$route', function(location) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
angular.foreach(onChange, parentScope.$tryEval);
|
angular.forEach(onChange, parentScope.$tryEval);
|
||||||
if (childScope) {
|
if (childScope) {
|
||||||
childScope.$become($route.current.controller);
|
childScope.$become($route.current.controller);
|
||||||
}
|
}
|
||||||
|
|
@ -817,7 +817,7 @@ angularServiceInject('$xhr.bulk', function($xhr, $error, $log){
|
||||||
post = _null;
|
post = _null;
|
||||||
}
|
}
|
||||||
var currentQueue;
|
var currentQueue;
|
||||||
foreach(bulkXHR.urls, function(queue){
|
forEach(bulkXHR.urls, function(queue){
|
||||||
if (isFunction(queue.match) ? queue.match(url) : queue.match.exec(url)) {
|
if (isFunction(queue.match) ? queue.match(url) : queue.match.exec(url)) {
|
||||||
currentQueue = queue;
|
currentQueue = queue;
|
||||||
}
|
}
|
||||||
|
|
@ -831,13 +831,13 @@ angularServiceInject('$xhr.bulk', function($xhr, $error, $log){
|
||||||
}
|
}
|
||||||
bulkXHR.urls = {};
|
bulkXHR.urls = {};
|
||||||
bulkXHR.flush = function(callback){
|
bulkXHR.flush = function(callback){
|
||||||
foreach(bulkXHR.urls, function(queue, url){
|
forEach(bulkXHR.urls, function(queue, url){
|
||||||
var currentRequests = queue.requests;
|
var currentRequests = queue.requests;
|
||||||
if (currentRequests && currentRequests.length) {
|
if (currentRequests && currentRequests.length) {
|
||||||
queue.requests = [];
|
queue.requests = [];
|
||||||
queue.callbacks = [];
|
queue.callbacks = [];
|
||||||
$xhr('POST', url, {requests:currentRequests}, function(code, response){
|
$xhr('POST', url, {requests:currentRequests}, function(code, response){
|
||||||
foreach(response, function(response, i){
|
forEach(response, function(response, i){
|
||||||
try {
|
try {
|
||||||
if (response.status == 200) {
|
if (response.status == 200) {
|
||||||
(currentRequests[i].callback || noop)(response.status, response.response);
|
(currentRequests[i].callback || noop)(response.status, response.response);
|
||||||
|
|
@ -926,7 +926,7 @@ angularServiceInject('$xhr.cache', function($xhr, $defer){
|
||||||
cache.data[url] = { value: response };
|
cache.data[url] = { value: response };
|
||||||
var callbacks = inflight[url].callbacks;
|
var callbacks = inflight[url].callbacks;
|
||||||
delete inflight[url];
|
delete inflight[url];
|
||||||
foreach(callbacks, function(callback){
|
forEach(callbacks, function(callback){
|
||||||
try {
|
try {
|
||||||
(callback||noop)(status, copy(response));
|
(callback||noop)(status, copy(response));
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
|
|
||||||
|
|
@ -359,15 +359,15 @@ function optionsAccessor(scope, element) {
|
||||||
return {
|
return {
|
||||||
get: function(){
|
get: function(){
|
||||||
var values = [];
|
var values = [];
|
||||||
foreach(options, function(option){
|
forEach(options, function(option){
|
||||||
if (option.selected) values.push(option.value);
|
if (option.selected) values.push(option.value);
|
||||||
});
|
});
|
||||||
return values;
|
return values;
|
||||||
},
|
},
|
||||||
set: function(values){
|
set: function(values){
|
||||||
var keys = {};
|
var keys = {};
|
||||||
foreach(values, function(value){ keys[value] = true; });
|
forEach(values, function(value){ keys[value] = true; });
|
||||||
foreach(options, function(option){
|
forEach(options, function(option){
|
||||||
option.selected = keys[option.value];
|
option.selected = keys[option.value];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -698,7 +698,7 @@ var ngSwitch = angularWidget('ng:switch', function (element){
|
||||||
if (isString(when)) {
|
if (isString(when)) {
|
||||||
switchCase.when = function(scope, value){
|
switchCase.when = function(scope, value){
|
||||||
var args = [value, when];
|
var args = [value, when];
|
||||||
foreach(usingExprParams, function(arg){
|
forEach(usingExprParams, function(arg){
|
||||||
args.push(arg);
|
args.push(arg);
|
||||||
});
|
});
|
||||||
return usingFn.apply(scope, args);
|
return usingFn.apply(scope, args);
|
||||||
|
|
@ -711,7 +711,7 @@ var ngSwitch = angularWidget('ng:switch', function (element){
|
||||||
});
|
});
|
||||||
|
|
||||||
// this needs to be here for IE
|
// this needs to be here for IE
|
||||||
foreach(cases, function(_case){
|
forEach(cases, function(_case){
|
||||||
_case.element.remove();
|
_case.element.remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -722,7 +722,7 @@ var ngSwitch = angularWidget('ng:switch', function (element){
|
||||||
var found = false;
|
var found = false;
|
||||||
element.html('');
|
element.html('');
|
||||||
childScope = createScope(scope);
|
childScope = createScope(scope);
|
||||||
foreach(cases, function(switchCase){
|
forEach(cases, function(switchCase){
|
||||||
if (!found && switchCase.when(childScope, value)) {
|
if (!found && switchCase.when(childScope, value)) {
|
||||||
found = true;
|
found = true;
|
||||||
var caseElement = quickClone(switchCase.element);
|
var caseElement = quickClone(switchCase.element);
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ describe('browser', function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
fakeSetTimeout.flush = function() {
|
fakeSetTimeout.flush = function() {
|
||||||
foreach(setTimeoutQueue, function(fn) {
|
forEach(setTimeoutQueue, function(fn) {
|
||||||
fn();
|
fn();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
4
test/angular-mocks.js
vendored
4
test/angular-mocks.js
vendored
|
|
@ -141,7 +141,7 @@ function MockBrowser() {
|
||||||
MockBrowser.prototype = {
|
MockBrowser.prototype = {
|
||||||
|
|
||||||
poll: function poll(){
|
poll: function poll(){
|
||||||
angular.foreach(this.pollFns, function(pollFn){
|
angular.forEach(this.pollFns, function(pollFn){
|
||||||
pollFn();
|
pollFn();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
@ -304,7 +304,7 @@ function TzDate(offset, timestamp) {
|
||||||
'setYear', 'toDateString', 'toJSON', 'toGMTString', 'toLocaleFormat', 'toLocaleString',
|
'setYear', 'toDateString', 'toJSON', 'toGMTString', 'toLocaleFormat', 'toLocaleString',
|
||||||
'toLocaleTimeString', 'toSource', 'toString', 'toTimeString', 'toUTCString', 'valueOf'];
|
'toLocaleTimeString', 'toSource', 'toString', 'toTimeString', 'toUTCString', 'valueOf'];
|
||||||
|
|
||||||
angular.foreach(unimplementedMethods, function(methodName) {
|
angular.forEach(unimplementedMethods, function(methodName) {
|
||||||
this[methodName] = function() {
|
this[methodName] = function() {
|
||||||
throw {
|
throw {
|
||||||
name: "MethodNotImplemented",
|
name: "MethodNotImplemented",
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ describe('angular.scenario.Runner', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should publish the functions in the public API', 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;
|
var func;
|
||||||
if (name in $window) {
|
if (name in $window) {
|
||||||
func = $window[name];
|
func = $window[name];
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ describe("angular.scenario.dsl", function() {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
$root.dsl = {};
|
$root.dsl = {};
|
||||||
angular.foreach(angular.scenario.dsl, function(fn, name) {
|
angular.forEach(angular.scenario.dsl, function(fn, name) {
|
||||||
$root.dsl[name] = function() {
|
$root.dsl[name] = function() {
|
||||||
return fn.call($root).apply($root, arguments);
|
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() {
|
it('should add all jQuery key/value methods', function() {
|
||||||
var METHODS = ['css', 'attr'];
|
var METHODS = ['css', 'attr'];
|
||||||
var chain = $root.dsl.element('input');
|
var chain = $root.dsl.element('input');
|
||||||
angular.foreach(METHODS, function(name) {
|
angular.forEach(METHODS, function(name) {
|
||||||
expect(angular.isFunction(chain[name])).toBeTruthy();
|
expect(angular.isFunction(chain[name])).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -316,7 +316,7 @@ describe("angular.scenario.dsl", function() {
|
||||||
'innerWidth', 'outerWidth', 'position', 'scrollLeft', 'scrollTop', 'offset'
|
'innerWidth', 'outerWidth', 'position', 'scrollLeft', 'scrollTop', 'offset'
|
||||||
];
|
];
|
||||||
var chain = $root.dsl.element('input');
|
var chain = $root.dsl.element('input');
|
||||||
angular.foreach(METHODS, function(name) {
|
angular.forEach(METHODS, function(name) {
|
||||||
expect(angular.isFunction(chain[name])).toBeTruthy();
|
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) {
|
angular.scenario.testing.MockRunner.prototype.emit = function(eventName) {
|
||||||
var args = Array.prototype.slice.call(arguments, 1);
|
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);
|
fn.apply(this, args);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -56,10 +56,10 @@ afterEach(clearJqCache);
|
||||||
|
|
||||||
function clearJqCache(){
|
function clearJqCache(){
|
||||||
var count = 0;
|
var count = 0;
|
||||||
foreachSorted(jqCache, function(value, key){
|
forEachSorted(jqCache, function(value, key){
|
||||||
count ++;
|
count ++;
|
||||||
delete jqCache[key];
|
delete jqCache[key];
|
||||||
foreach(value, function(value, key){
|
forEach(value, function(value, key){
|
||||||
if (value.$element)
|
if (value.$element)
|
||||||
dump(key, sortedHtml(value.$element));
|
dump(key, sortedHtml(value.$element));
|
||||||
else
|
else
|
||||||
|
|
@ -91,7 +91,7 @@ extend(angular, {
|
||||||
'copy': copy,
|
'copy': copy,
|
||||||
'extend': extend,
|
'extend': extend,
|
||||||
'equals': equals,
|
'equals': equals,
|
||||||
'foreach': foreach,
|
'forEach': forEach,
|
||||||
'noop':noop,
|
'noop':noop,
|
||||||
'bind':bind,
|
'bind':bind,
|
||||||
'toJson': toJson,
|
'toJson': toJson,
|
||||||
|
|
@ -103,13 +103,14 @@ extend(angular, {
|
||||||
'isFunction': isFunction,
|
'isFunction': isFunction,
|
||||||
'isObject': isObject,
|
'isObject': isObject,
|
||||||
'isNumber': isNumber,
|
'isNumber': isNumber,
|
||||||
'isArray': isArray
|
'isArray': isArray,
|
||||||
|
'forEach': forEach
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function sortedHtml(element, showNgClass) {
|
function sortedHtml(element, showNgClass) {
|
||||||
var html = "";
|
var html = "";
|
||||||
foreach(jqLite(element), function toString(node) {
|
forEach(jqLite(element), function toString(node) {
|
||||||
if (node.nodeName == "#text") {
|
if (node.nodeName == "#text") {
|
||||||
html += node.nodeValue.
|
html += node.nodeValue.
|
||||||
replace(/&(\w+[&;\W])?/g, function(match, entity){return entity?match:'&';}).
|
replace(/&(\w+[&;\W])?/g, function(match, entity){return entity?match:'&';}).
|
||||||
|
|
@ -155,7 +156,7 @@ function sortedHtml(element, showNgClass) {
|
||||||
if (node.style) {
|
if (node.style) {
|
||||||
var style = [];
|
var style = [];
|
||||||
if (node.style.cssText) {
|
if (node.style.cssText) {
|
||||||
foreach(node.style.cssText.split(';'), function(value){
|
forEach(node.style.cssText.split(';'), function(value){
|
||||||
value = trim(value);
|
value = trim(value);
|
||||||
if (value) {
|
if (value) {
|
||||||
style.push(lowercase(value));
|
style.push(lowercase(value));
|
||||||
|
|
@ -174,7 +175,7 @@ function sortedHtml(element, showNgClass) {
|
||||||
style.sort();
|
style.sort();
|
||||||
var tmp = style;
|
var tmp = style;
|
||||||
style = [];
|
style = [];
|
||||||
foreach(tmp, function(value){
|
forEach(tmp, function(value){
|
||||||
if (!value.match(/^max[^\-]/))
|
if (!value.match(/^max[^\-]/))
|
||||||
style.push(value);
|
style.push(value);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue