diff options
| author | Misko Hevery | 2011-03-23 09:33:29 -0700 |
|---|---|---|
| committer | Vojta Jina | 2011-08-02 01:00:03 +0200 |
| commit | 8f0dcbab804180828d6859b1340c86cf161209fb (patch) | |
| tree | d13d47d47a1889cb7c96a87cecacd2e25307d51c /src/apis.js | |
| parent | 1f4b417184ce53af15474de065400f8a686430c5 (diff) | |
| download | angular.js-8f0dcbab804180828d6859b1340c86cf161209fb.tar.bz2 | |
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
Diffstat (limited to 'src/apis.js')
| -rw-r--r-- | src/apis.js | 24 |
1 files changed, 12 insertions, 12 deletions
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 = { </doc:example> */ '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 = { </doc:source> <doc:scenario> 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'); }); </doc:scenario> </doc:example> */ '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; + } } }; |
