From f3a796e522afdbd3b640d14426edb2fbfab463c5 Mon Sep 17 00:00:00 2001 From: Karl Seamon Date: Wed, 18 Dec 2013 15:45:56 -0500 Subject: [PATCH] perf(compile): add class 'ng-scope' before cloning and other micro-optimizations Add class ng-scope to dom nodes during directive compile rather than link. Optimize handling of nodeLists. This results in a savings of about 130ms during the startup of a product within Google. Closes #5471 --- src/ng/compile.js | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/ng/compile.js b/src/ng/compile.js index 9b7d05aaad0e..3e5a2479cb6e 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -818,6 +818,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { var compositeLinkFn = compileNodes($compileNodes, transcludeFn, $compileNodes, maxPriority, ignoreDirective, previousCompileContext); + safeAddClass($compileNodes, 'ng-scope'); return function publicLinkFn(scope, cloneConnectFn, transcludeControllers){ assertArg(scope, 'scope'); // important!!: we must call our jqLite.clone() since the jQuery one is trying to be smart @@ -832,12 +833,13 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { // Attach scope only to non-text nodes. for(var i = 0, ii = $linkNode.length; i