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

Commit a160f76

Browse files
jbedardrodyhaddad
authored andcommitted
perf($compile): only create jqLite object when necessary
1 parent d181726 commit a160f76

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
@@ -931,7 +931,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
931931
: null;
932932

933933
if (nodeLinkFn && nodeLinkFn.scope) {
934-
safeAddClass(jqLite(nodeList[i]), 'ng-scope');
934+
safeAddClass(attrs.$$element, 'ng-scope');
935935
}
936936

937937
childLinkFn = (nodeLinkFn && nodeLinkFn.terminal ||
@@ -953,7 +953,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
953953
return linkFnFound ? compositeLinkFn : null;
954954

955955
function compositeLinkFn(scope, nodeList, $rootElement, parentBoundTranscludeFn) {
956-
var nodeLinkFn, childLinkFn, node, $node, childScope, i, ii, n, childBoundTranscludeFn;
956+
var nodeLinkFn, childLinkFn, node, childScope, i, ii, n, childBoundTranscludeFn;
957957

958958
// copy nodeList so that linking doesn't break due to live list updates.
959959
var nodeListLength = nodeList.length,
@@ -966,12 +966,11 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
966966
node = stableNodeList[n];
967967
nodeLinkFn = linkFns[i++];
968968
childLinkFn = linkFns[i++];
969-
$node = jqLite(node);
970969

971970
if (nodeLinkFn) {
972971
if (nodeLinkFn.scope) {
973972
childScope = scope.$new();
974-
$node.data('$scope', childScope);
973+
jqLite(node).data('$scope', childScope);
975974
} else {
976975
childScope = scope;
977976
}
@@ -1273,12 +1272,12 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
12731272
if (directiveValue == 'element') {
12741273
hasElementTranscludeDirective = true;
12751274
terminalPriority = directive.priority;
1276-
$template = groupScan(compileNode, attrStart, attrEnd);
1275+
$template = $compileNode;
12771276
$compileNode = templateAttrs.$$element =
12781277
jqLite(document.createComment(' ' + directiveName + ': ' +
12791278
templateAttrs[directiveName] + ' '));
12801279
compileNode = $compileNode[0];
1281-
replaceWith(jqCollection, jqLite(sliceArgs($template)), compileNode);
1280+
replaceWith(jqCollection, sliceArgs($template), compileNode);
12821281

12831282
childTranscludeFn = compile($template, transcludeFn, terminalPriority,
12841283
replaceDirective && replaceDirective.name, {
@@ -1462,20 +1461,19 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
14621461

14631462
if (newIsolateScopeDirective) {
14641463
var LOCAL_REGEXP = /^\s*([@=&])(\??)\s*(\w*)\s*$/;
1465-
var $linkNode = jqLite(linkNode);
14661464

14671465
isolateScope = scope.$new(true);
14681466

14691467
if (templateDirective && (templateDirective === newIsolateScopeDirective ||
14701468
templateDirective === newIsolateScopeDirective.$$originalDirective)) {
1471-
$linkNode.data('$isolateScope', isolateScope) ;
1469+
$element.data('$isolateScope', isolateScope);
14721470
} else {
1473-
$linkNode.data('$isolateScopeNoTemplate', isolateScope);
1471+
$element.data('$isolateScopeNoTemplate', isolateScope);
14741472
}
14751473

14761474

14771475

1478-
safeAddClass($linkNode, 'ng-isolate-scope');
1476+
safeAddClass($element, 'ng-isolate-scope');
14791477

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

0 commit comments

Comments
 (0)