From 8f0dcbab804180828d6859b1340c86cf161209fb Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Wed, 23 Mar 2011 09:33:29 -0700 Subject: feat(scope): new and improved scope implementation - Speed improvements (about 4x on flush phase) - Memory improvements (uses no function closures) - Break $eval into $apply, $dispatch, $flush - Introduced $watch and $observe Breaks angular.equals() use === instead of == Breaks angular.scope() does not take parent as first argument Breaks scope.$watch() takes scope as first argument Breaks scope.$set(), scope.$get are removed Breaks scope.$config is removed Breaks $route.onChange callback has not "this" bounded --- src/apis.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/apis.js') diff --git a/src/apis.js b/src/apis.js index 3ccd95d7..8a566a46 100644 --- a/src/apis.js +++ b/src/apis.js @@ -7,7 +7,7 @@ var angularGlobal = { if (type == $object) { if (obj instanceof Array) return $array; if (isDate(obj)) return $date; - if (obj.nodeType == 1) return $element; + if (obj.nodeType == 1) return 'element'; } return type; } @@ -180,7 +180,7 @@ var angularArray = { */ 'sum':function(array, expression) { - var fn = angular['Function']['compile'](expression); + var fn = angularFunction.compile(expression); var sum = 0; for (var i = 0; i < array.length; i++) { var value = 1 * fn(array[i]); @@ -522,21 +522,21 @@ var angularArray = { it('should calculate counts', function() { - expect(binding('items.$count(\'points==1\')')).toEqual(2); - expect(binding('items.$count(\'points>1\')')).toEqual(1); + expect(binding('items.$count(\'points==1\')')).toEqual('2'); + expect(binding('items.$count(\'points>1\')')).toEqual('1'); }); it('should recalculate when updated', function() { using('.doc-example-live li:first-child').input('item.points').enter('23'); - expect(binding('items.$count(\'points==1\')')).toEqual(1); - expect(binding('items.$count(\'points>1\')')).toEqual(2); + expect(binding('items.$count(\'points==1\')')).toEqual('1'); + expect(binding('items.$count(\'points>1\')')).toEqual('2'); }); */ 'count':function(array, condition) { if (!condition) return array.length; - var fn = angular['Function']['compile'](condition), count = 0; + var fn = angularFunction.compile(condition), count = 0; forEach(array, function(value){ if (fn(value)) { count ++; @@ -635,7 +635,7 @@ var angularArray = { descending = predicate.charAt(0) == '-'; predicate = predicate.substring(1); } - get = expressionCompile(predicate).fnSelf; + get = expressionCompile(predicate); } return reverseComparator(function(a,b){ return compare(get(a),get(b)); @@ -796,14 +796,14 @@ var angularDate = { }; var angularFunction = { - 'compile':function(expression) { + 'compile': function(expression) { if (isFunction(expression)){ return expression; } else if (expression){ - return expressionCompile(expression).fnSelf; + return expressionCompile(expression); } else { - return identity; - } + return identity; + } } }; -- cgit v1.2.3