Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 71eb190

Browse files
jbedardrodyhaddad
authored andcommitted
perf($compile): only create jqLite object when necessary
1 parent 4e57e28 commit 71eb190

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/ng/compile.js

+8-10
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
908908
: null;
909909

910910
if (nodeLinkFn && nodeLinkFn.scope) {
911-
safeAddClass(jqLite(nodeList[i]), 'ng-scope');
911+
safeAddClass(attrs.$$element, 'ng-scope');
912912
}
913913

914914
childLinkFn = (nodeLinkFn && nodeLinkFn.terminal ||
@@ -930,7 +930,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
930930
return linkFnFound ? compositeLinkFn : null;
931931

932932
function compositeLinkFn(scope, nodeList, $rootElement, parentBoundTranscludeFn) {
933-
var nodeLinkFn, childLinkFn, node, $node, childScope, i, ii, n, childBoundTranscludeFn;
933+
var nodeLinkFn, childLinkFn, node, childScope, i, ii, n, childBoundTranscludeFn;
934934

935935
// copy nodeList so that linking doesn't break due to live list updates.
936936
var nodeListLength = nodeList.length,
@@ -943,12 +943,11 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
943943
node = stableNodeList[n];
944944
nodeLinkFn = linkFns[i++];
945945
childLinkFn = linkFns[i++];
946-
$node = jqLite(node);
947946

948947
if (nodeLinkFn) {
949948
if (nodeLinkFn.scope) {
950949
childScope = scope.$new();
951-
$node.data('$scope', childScope);
950+
jqLite(node).data('$scope', childScope);
952951
} else {
953952
childScope = scope;
954953
}
@@ -1240,12 +1239,12 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
12401239
if (directiveValue == 'element') {
12411240
hasElementTranscludeDirective = true;
12421241
terminalPriority = directive.priority;
1243-
$template = groupScan(compileNode, attrStart, attrEnd);
1242+
$template = $compileNode;
12441243
$compileNode = templateAttrs.$$element =
12451244
jqLite(document.createComment(' ' + directiveName + ': ' +
12461245
templateAttrs[directiveName] + ' '));
12471246
compileNode = $compileNode[0];
1248-
replaceWith(jqCollection, jqLite(sliceArgs($template)), compileNode);
1247+
replaceWith(jqCollection, sliceArgs($template), compileNode);
12491248

12501249
childTranscludeFn = compile($template, transcludeFn, terminalPriority,
12511250
replaceDirective && replaceDirective.name, {
@@ -1429,20 +1428,19 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
14291428

14301429
if (newIsolateScopeDirective) {
14311430
var LOCAL_REGEXP = /^\s*([@=&])(\??)\s*(\w*)\s*$/;
1432-
var $linkNode = jqLite(linkNode);
14331431

14341432
isolateScope = scope.$new(true);
14351433

14361434
if (templateDirective && (templateDirective === newIsolateScopeDirective ||
14371435
templateDirective === newIsolateScopeDirective.$$originalDirective)) {
1438-
$linkNode.data('$isolateScope', isolateScope) ;
1436+
$element.data('$isolateScope', isolateScope);
14391437
} else {
1440-
$linkNode.data('$isolateScopeNoTemplate', isolateScope);
1438+
$element.data('$isolateScopeNoTemplate', isolateScope);
14411439
}
14421440

14431441

14441442

1445-
safeAddClass($linkNode, 'ng-isolate-scope');
1443+
safeAddClass($element, 'ng-isolate-scope');
14461444

14471445
forEach(newIsolateScopeDirective.scope, function(definition, scopeName) {
14481446
var match = definition.match(LOCAL_REGEXP) || [],

0 commit comments

Comments
 (0)