From 3410f65e790a81d457b4f4601a1e760a6f8ede5e Mon Sep 17 00:00:00 2001 From: Michał Gołębiowski Date: Wed, 16 Oct 2013 15:15:21 +0200 Subject: 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 --- test/ng/compileSpec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/ng/compileSpec.js') 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('
'); $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 ) element = jqLite('
xxx
'); $compile(element.contents())($rootScope); - element.html(''); + element.empty(); expect(calcCacheSize()).toEqual(0); // Next with comment nodes at the top level element = jqLite('
'); $compile(element.contents())($rootScope); - element.html(''); + element.empty(); expect(calcCacheSize()).toEqual(0); // Finally with empty text nodes at the top level element = jqLite('
\n
'); $compile(element.contents())($rootScope); - element.html(''); + element.empty(); expect(calcCacheSize()).toEqual(0); }); -- cgit v1.2.3