mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-01-13 08:59:54 +08:00
committed by
Peter Bacon Darwin
parent
8b921617e9
commit
31ec9f14ef
@@ -8,5 +8,6 @@
|
||||
"disallowSpaceBeforeBinaryOperators": [","],
|
||||
"disallowTrailingComma": true,
|
||||
"disallowTrailingWhitespace": true,
|
||||
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"]
|
||||
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"],
|
||||
"validateParameterSeparator": ", "
|
||||
}
|
||||
|
||||
@@ -1870,7 +1870,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
if (parentGet.literal) {
|
||||
compare = equals;
|
||||
} else {
|
||||
compare = function(a,b) { return a === b || (a !== a && b !== b); };
|
||||
compare = function(a, b) { return a === b || (a !== a && b !== b); };
|
||||
}
|
||||
parentSet = parentGet.assign || function() {
|
||||
// reset the change, or we will throw this exception on every $digest
|
||||
|
||||
@@ -130,19 +130,19 @@ function orderByFilter($parse){
|
||||
}
|
||||
if ( predicate === '' ) {
|
||||
// Effectively no predicate was passed so we compare identity
|
||||
return reverseComparator(function(a,b) {
|
||||
return reverseComparator(function(a, b) {
|
||||
return compare(a, b);
|
||||
}, descending);
|
||||
}
|
||||
get = $parse(predicate);
|
||||
if (get.constant) {
|
||||
var key = get();
|
||||
return reverseComparator(function(a,b) {
|
||||
return reverseComparator(function(a, b) {
|
||||
return compare(a[key], b[key]);
|
||||
}, descending);
|
||||
}
|
||||
}
|
||||
return reverseComparator(function(a,b){
|
||||
return reverseComparator(function(a, b){
|
||||
return compare(get(a),get(b));
|
||||
}, descending);
|
||||
});
|
||||
@@ -159,7 +159,7 @@ function orderByFilter($parse){
|
||||
}
|
||||
function reverseComparator(comp, descending) {
|
||||
return descending
|
||||
? function(a,b){return comp(b,a);}
|
||||
? function(a, b){return comp(b,a);}
|
||||
: comp;
|
||||
}
|
||||
function compare(v1, v2){
|
||||
|
||||
@@ -99,7 +99,7 @@ CONSTANTS['this'].sharedGetter = true;
|
||||
|
||||
//Operators - will be wrapped by binaryFn/unaryFn/assignment/filter
|
||||
var OPERATORS = extend(createMap(), {
|
||||
'+':function(self, locals, a,b){
|
||||
'+':function(self, locals, a, b){
|
||||
a=a(self, locals); b=b(self, locals);
|
||||
if (isDefined(a)) {
|
||||
if (isDefined(b)) {
|
||||
@@ -108,23 +108,23 @@ var OPERATORS = extend(createMap(), {
|
||||
return a;
|
||||
}
|
||||
return isDefined(b)?b:undefined;},
|
||||
'-':function(self, locals, a,b){
|
||||
'-':function(self, locals, a, b){
|
||||
a=a(self, locals); b=b(self, locals);
|
||||
return (isDefined(a)?a:0)-(isDefined(b)?b:0);
|
||||
},
|
||||
'*':function(self, locals, a,b){return a(self, locals)*b(self, locals);},
|
||||
'/':function(self, locals, a,b){return a(self, locals)/b(self, locals);},
|
||||
'%':function(self, locals, a,b){return a(self, locals)%b(self, locals);},
|
||||
'*':function(self, locals, a, b){return a(self, locals)*b(self, locals);},
|
||||
'/':function(self, locals, a, b){return a(self, locals)/b(self, locals);},
|
||||
'%':function(self, locals, a, b){return a(self, locals)%b(self, locals);},
|
||||
'===':function(self, locals, a, b){return a(self, locals)===b(self, locals);},
|
||||
'!==':function(self, locals, a, b){return a(self, locals)!==b(self, locals);},
|
||||
'==':function(self, locals, a,b){return a(self, locals)==b(self, locals);},
|
||||
'!=':function(self, locals, a,b){return a(self, locals)!=b(self, locals);},
|
||||
'<':function(self, locals, a,b){return a(self, locals)<b(self, locals);},
|
||||
'>':function(self, locals, a,b){return a(self, locals)>b(self, locals);},
|
||||
'<=':function(self, locals, a,b){return a(self, locals)<=b(self, locals);},
|
||||
'>=':function(self, locals, a,b){return a(self, locals)>=b(self, locals);},
|
||||
'&&':function(self, locals, a,b){return a(self, locals)&&b(self, locals);},
|
||||
'||':function(self, locals, a,b){return a(self, locals)||b(self, locals);},
|
||||
'==':function(self, locals, a, b){return a(self, locals)==b(self, locals);},
|
||||
'!=':function(self, locals, a, b){return a(self, locals)!=b(self, locals);},
|
||||
'<':function(self, locals, a, b){return a(self, locals)<b(self, locals);},
|
||||
'>':function(self, locals, a, b){return a(self, locals)>b(self, locals);},
|
||||
'<=':function(self, locals, a, b){return a(self, locals)<=b(self, locals);},
|
||||
'>=':function(self, locals, a, b){return a(self, locals)>=b(self, locals);},
|
||||
'&&':function(self, locals, a, b){return a(self, locals)&&b(self, locals);},
|
||||
'||':function(self, locals, a, b){return a(self, locals)||b(self, locals);},
|
||||
'!':function(self, locals, a){return !a(self, locals);},
|
||||
|
||||
//Tokenized as operators but parsed as assignment/filters
|
||||
|
||||
6
src/ngMock/angular-mocks.js
vendored
6
src/ngMock/angular-mocks.js
vendored
@@ -67,7 +67,7 @@ angular.mock.$Browser = function() {
|
||||
self.defer = function(fn, delay) {
|
||||
delay = delay || 0;
|
||||
self.deferredFns.push({time:(self.defer.now + delay), fn:fn, id: self.deferredNextId});
|
||||
self.deferredFns.sort(function(a,b){ return a.time - b.time;});
|
||||
self.deferredFns.sort(function(a, b){ return a.time - b.time;});
|
||||
return self.deferredNextId++;
|
||||
};
|
||||
|
||||
@@ -497,7 +497,7 @@ angular.mock.$IntervalProvider = function() {
|
||||
id: nextRepeatId,
|
||||
deferred: deferred
|
||||
});
|
||||
repeatFns.sort(function(a,b){ return a.nextTime - b.nextTime;});
|
||||
repeatFns.sort(function(a, b){ return a.nextTime - b.nextTime;});
|
||||
|
||||
nextRepeatId++;
|
||||
return promise;
|
||||
@@ -546,7 +546,7 @@ angular.mock.$IntervalProvider = function() {
|
||||
var task = repeatFns[0];
|
||||
task.fn();
|
||||
task.nextTime += task.delay;
|
||||
repeatFns.sort(function(a,b){ return a.nextTime - b.nextTime;});
|
||||
repeatFns.sort(function(a, b){ return a.nextTime - b.nextTime;});
|
||||
}
|
||||
return millis;
|
||||
};
|
||||
|
||||
@@ -160,7 +160,7 @@ describe('Filter: filter', function() {
|
||||
{key: 1, nonkey:14}
|
||||
];
|
||||
var expr = {key: 10};
|
||||
var comparator = function (obj,value) {
|
||||
var comparator = function (obj, value) {
|
||||
return obj > value;
|
||||
};
|
||||
expect(filter(items, expr, comparator)).toEqual([items[2]]);
|
||||
|
||||
@@ -17,7 +17,7 @@ describe('$interval', function() {
|
||||
fn: fn,
|
||||
id: nextRepeatId
|
||||
});
|
||||
repeatFns.sort(function(a,b){ return a.nextTime - b.nextTime;});
|
||||
repeatFns.sort(function(a, b){ return a.nextTime - b.nextTime;});
|
||||
|
||||
return nextRepeatId++;
|
||||
},
|
||||
@@ -43,7 +43,7 @@ describe('$interval', function() {
|
||||
var task = repeatFns[0];
|
||||
task.fn();
|
||||
task.nextTime += task.delay;
|
||||
repeatFns.sort(function(a,b){ return a.nextTime - b.nextTime;});
|
||||
repeatFns.sort(function(a, b){ return a.nextTime - b.nextTime;});
|
||||
}
|
||||
return millis;
|
||||
}
|
||||
|
||||
@@ -463,12 +463,12 @@ describe('parser', function() {
|
||||
});
|
||||
|
||||
it('should evaluate function call without arguments', function() {
|
||||
scope['const'] = function(a,b){return 123;};
|
||||
scope['const'] = function(a, b){return 123;};
|
||||
expect(scope.$eval("const()")).toEqual(123);
|
||||
});
|
||||
|
||||
it('should evaluate function call with arguments', function() {
|
||||
scope.add = function(a,b) {
|
||||
scope.add = function(a, b) {
|
||||
return a+b;
|
||||
};
|
||||
expect(scope.$eval("add(1,2)")).toEqual(3);
|
||||
|
||||
Reference in New Issue
Block a user