mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
parent
f299fd5122
commit
42c38b29f7
2 changed files with 35 additions and 1 deletions
|
|
@ -5,7 +5,15 @@ var OPERATORS = {
|
|||
'true':function(){return true;},
|
||||
'false':function(){return false;},
|
||||
undefined:noop,
|
||||
'+':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){
|
||||
a=a(self, locals); b=b(self, locals);
|
||||
if (isDefined(a)) {
|
||||
if (isDefined(b)) {
|
||||
return a + b;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
return isDefined(b)?b:undefined;},
|
||||
'-':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);},
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ describe('$interpolate', function() {
|
|||
|
||||
it('should suppress falsy objects', inject(function($interpolate) {
|
||||
expect($interpolate('{{undefined}}')()).toEqual('');
|
||||
expect($interpolate('{{undefined+undefined}}')()).toEqual('');
|
||||
expect($interpolate('{{null}}')()).toEqual('');
|
||||
expect($interpolate('{{a.b}}')()).toEqual('');
|
||||
}));
|
||||
|
|
@ -55,6 +56,31 @@ describe('$interpolate', function() {
|
|||
}));
|
||||
|
||||
|
||||
it('should ignore undefined model', inject(function($interpolate) {
|
||||
expect($interpolate("Hello {{'World' + foo}}")()).toEqual('Hello World');
|
||||
}));
|
||||
|
||||
|
||||
it('should ignore undefined return value', inject(function($interpolate, $rootScope) {
|
||||
$rootScope.foo = function() {return undefined};
|
||||
expect($interpolate("Hello {{'World' + foo()}}")($rootScope)).toEqual('Hello World');
|
||||
}));
|
||||
|
||||
|
||||
describe('provider', function() {
|
||||
beforeEach(module(function($interpolateProvider) {
|
||||
$interpolateProvider.startSymbol('--');
|
||||
$interpolateProvider.endSymbol('--');
|
||||
}));
|
||||
|
||||
it('should not get confused with same markers', inject(function($interpolate) {
|
||||
expect($interpolate('---').parts).toEqual(['---']);
|
||||
expect($interpolate('----')()).toEqual('');
|
||||
expect($interpolate('--1--')()).toEqual('1');
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
describe('parseBindings', function() {
|
||||
it('should Parse Text With No Bindings', inject(function($interpolate) {
|
||||
var parts = $interpolate("a").parts;
|
||||
|
|
|
|||
Loading…
Reference in a new issue