diff options
| author | Michał Gołębiowski | 2013-10-16 15:15:21 +0200 | 
|---|---|---|
| committer | Igor Minar | 2013-12-13 02:07:11 -0800 | 
| commit | 3410f65e790a81d457b4f4601a1e760a6f8ede5e (patch) | |
| tree | 2f37146f1399d23ea02de44e8209879eda949e1f /test/ng/compileSpec.js | |
| parent | f3de5b6eac90baf649506072162f36dbc6d2f028 (diff) | |
| download | angular.js-3410f65e790a81d457b4f4601a1e760a6f8ede5e.tar.bz2 | |
perf(jqLite): implement and use the `empty` method in place of `html(‘’)`
jQuery's elem.html('') is way slower than elem.empty(). As clearing
element contents happens quite often in certain scenarios, switching
to using .empty() provides a significant performance boost when using
Angular with jQuery.
Closes #4457
Diffstat (limited to 'test/ng/compileSpec.js')
| -rwxr-xr-x | test/ng/compileSpec.js | 8 | 
1 files changed, 4 insertions, 4 deletions
| diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 853290a6..1b98cd58 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -170,26 +170,26 @@ describe('$compile', function() {        // First with only elements at the top level        element = jqLite('<div><div></div></div>');        $compile(element.contents())($rootScope); -      element.html(''); +      element.empty();        expect(calcCacheSize()).toEqual(0);        // Next with non-empty text nodes at the top level        // (in this case the compiler will wrap them in a <span>)        element = jqLite('<div>xxx</div>');        $compile(element.contents())($rootScope); -      element.html(''); +      element.empty();        expect(calcCacheSize()).toEqual(0);        // Next with comment nodes at the top level        element = jqLite('<div><!-- comment --></div>');        $compile(element.contents())($rootScope); -      element.html(''); +      element.empty();        expect(calcCacheSize()).toEqual(0);        // Finally with empty text nodes at the top level        element = jqLite('<div>   \n<div></div>   </div>');        $compile(element.contents())($rootScope); -      element.html(''); +      element.empty();        expect(calcCacheSize()).toEqual(0);      }); | 
