mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-19 13:05:57 +08:00
perf($compile): only create jqLite object when necessary
This commit is contained in:
@@ -908,7 +908,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
: null;
|
||||
|
||||
if (nodeLinkFn && nodeLinkFn.scope) {
|
||||
safeAddClass(jqLite(nodeList[i]), 'ng-scope');
|
||||
safeAddClass(attrs.$$element, 'ng-scope');
|
||||
}
|
||||
|
||||
childLinkFn = (nodeLinkFn && nodeLinkFn.terminal ||
|
||||
@@ -930,7 +930,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
return linkFnFound ? compositeLinkFn : null;
|
||||
|
||||
function compositeLinkFn(scope, nodeList, $rootElement, parentBoundTranscludeFn) {
|
||||
var nodeLinkFn, childLinkFn, node, $node, childScope, i, ii, n, childBoundTranscludeFn;
|
||||
var nodeLinkFn, childLinkFn, node, childScope, i, ii, n, childBoundTranscludeFn;
|
||||
|
||||
// copy nodeList so that linking doesn't break due to live list updates.
|
||||
var nodeListLength = nodeList.length,
|
||||
@@ -943,12 +943,11 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
node = stableNodeList[n];
|
||||
nodeLinkFn = linkFns[i++];
|
||||
childLinkFn = linkFns[i++];
|
||||
$node = jqLite(node);
|
||||
|
||||
if (nodeLinkFn) {
|
||||
if (nodeLinkFn.scope) {
|
||||
childScope = scope.$new();
|
||||
$node.data('$scope', childScope);
|
||||
jqLite(node).data('$scope', childScope);
|
||||
} else {
|
||||
childScope = scope;
|
||||
}
|
||||
@@ -1240,12 +1239,12 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
if (directiveValue == 'element') {
|
||||
hasElementTranscludeDirective = true;
|
||||
terminalPriority = directive.priority;
|
||||
$template = groupScan(compileNode, attrStart, attrEnd);
|
||||
$template = $compileNode;
|
||||
$compileNode = templateAttrs.$$element =
|
||||
jqLite(document.createComment(' ' + directiveName + ': ' +
|
||||
templateAttrs[directiveName] + ' '));
|
||||
compileNode = $compileNode[0];
|
||||
replaceWith(jqCollection, jqLite(sliceArgs($template)), compileNode);
|
||||
replaceWith(jqCollection, sliceArgs($template), compileNode);
|
||||
|
||||
childTranscludeFn = compile($template, transcludeFn, terminalPriority,
|
||||
replaceDirective && replaceDirective.name, {
|
||||
@@ -1429,20 +1428,19 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
|
||||
if (newIsolateScopeDirective) {
|
||||
var LOCAL_REGEXP = /^\s*([@=&])(\??)\s*(\w*)\s*$/;
|
||||
var $linkNode = jqLite(linkNode);
|
||||
|
||||
isolateScope = scope.$new(true);
|
||||
|
||||
if (templateDirective && (templateDirective === newIsolateScopeDirective ||
|
||||
templateDirective === newIsolateScopeDirective.$$originalDirective)) {
|
||||
$linkNode.data('$isolateScope', isolateScope) ;
|
||||
$element.data('$isolateScope', isolateScope);
|
||||
} else {
|
||||
$linkNode.data('$isolateScopeNoTemplate', isolateScope);
|
||||
$element.data('$isolateScopeNoTemplate', isolateScope);
|
||||
}
|
||||
|
||||
|
||||
|
||||
safeAddClass($linkNode, 'ng-isolate-scope');
|
||||
safeAddClass($element, 'ng-isolate-scope');
|
||||
|
||||
forEach(newIsolateScopeDirective.scope, function(definition, scopeName) {
|
||||
var match = definition.match(LOCAL_REGEXP) || [],
|
||||
|
||||
Reference in New Issue
Block a user