From dc5bd4d204592fa639ece8fffe6b59ca8d9fa793 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. --- 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 0af76a758caa..979fc592ebbb 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