mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-08 23:04:45 +00:00
style($compile): better fn names for debugging
This commit is contained in:
parent
b936236fbc
commit
524c5c8b5d
1 changed files with 24 additions and 23 deletions
|
|
@ -310,26 +310,26 @@ function $CompileProvider($provide) {
|
||||||
|
|
||||||
//================================
|
//================================
|
||||||
|
|
||||||
function compile($compileNode, transcludeFn, maxPriority) {
|
function compile($compileNodes, transcludeFn, maxPriority) {
|
||||||
if (!($compileNode instanceof jqLite)) {
|
if (!($compileNodes instanceof jqLite)) {
|
||||||
// jquery always rewraps, where as we need to preserve the original selector so that we can modify it.
|
// jquery always rewraps, where as we need to preserve the original selector so that we can modify it.
|
||||||
$compileNode = jqLite($compileNode);
|
$compileNodes = jqLite($compileNodes);
|
||||||
}
|
}
|
||||||
// We can not compile top level text elements since text nodes can be merged and we will
|
// We can not compile top level text elements since text nodes can be merged and we will
|
||||||
// not be able to attach scope data to them, so we will wrap them in <span>
|
// not be able to attach scope data to them, so we will wrap them in <span>
|
||||||
forEach($compileNode, function(node, index){
|
forEach($compileNodes, function(node, index){
|
||||||
if (node.nodeType == 3 /* text node */) {
|
if (node.nodeType == 3 /* text node */) {
|
||||||
$compileNode[index] = jqLite(node).wrap('<span></span>').parent()[0];
|
$compileNodes[index] = jqLite(node).wrap('<span></span>').parent()[0];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var compositeLinkFn = compileNodes($compileNode, transcludeFn, $compileNode, maxPriority);
|
var compositeLinkFn = compileNodes($compileNodes, transcludeFn, $compileNodes, maxPriority);
|
||||||
return function(scope, cloneConnectFn){
|
return function publicLinkFn(scope, cloneConnectFn){
|
||||||
assertArg(scope, 'scope');
|
assertArg(scope, 'scope');
|
||||||
// important!!: we must call our jqLite.clone() since the jQuery one is trying to be smart
|
// important!!: we must call our jqLite.clone() since the jQuery one is trying to be smart
|
||||||
// and sometimes changes the structure of the DOM.
|
// and sometimes changes the structure of the DOM.
|
||||||
var $linkNode = cloneConnectFn
|
var $linkNode = cloneConnectFn
|
||||||
? JQLitePrototype.clone.call($compileNode) // IMPORTANT!!!
|
? JQLitePrototype.clone.call($compileNodes) // IMPORTANT!!!
|
||||||
: $compileNode;
|
: $compileNodes;
|
||||||
$linkNode.data('$scope', scope);
|
$linkNode.data('$scope', scope);
|
||||||
safeAddClass($linkNode, 'ng-scope');
|
safeAddClass($linkNode, 'ng-scope');
|
||||||
if (cloneConnectFn) cloneConnectFn($linkNode, scope);
|
if (cloneConnectFn) cloneConnectFn($linkNode, scope);
|
||||||
|
|
@ -432,13 +432,14 @@ function $CompileProvider($provide) {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks for directives on the given node ands them to the directive collection which is sorted.
|
* Looks for directives on the given node and adds them to the directive collection which is
|
||||||
|
* sorted.
|
||||||
*
|
*
|
||||||
* @param node node to search
|
* @param node Node to search.
|
||||||
* @param directives an array to which the directives are added to. This array is sorted before
|
* @param directives An array to which the directives are added to. This array is sorted before
|
||||||
* the function returns.
|
* the function returns.
|
||||||
* @param attrs the shared attrs object which is used to populate the normalized attributes.
|
* @param attrs The shared attrs object which is used to populate the normalized attributes.
|
||||||
* @param {number=} max directive priority
|
* @param {number=} maxPriority Max directive priority.
|
||||||
*/
|
*/
|
||||||
function collectDirectives(node, directives, attrs, maxPriority) {
|
function collectDirectives(node, directives, attrs, maxPriority) {
|
||||||
var nodeType = node.nodeType,
|
var nodeType = node.nodeType,
|
||||||
|
|
@ -527,7 +528,7 @@ function $CompileProvider($provide) {
|
||||||
preLinkFns = [],
|
preLinkFns = [],
|
||||||
postLinkFns = [],
|
postLinkFns = [],
|
||||||
newScopeDirective = null,
|
newScopeDirective = null,
|
||||||
newIsolatedScopeDirective = null,
|
newIsolateScopeDirective = null,
|
||||||
templateDirective = null,
|
templateDirective = null,
|
||||||
$compileNode = templateAttrs.$$element = jqLite(compileNode),
|
$compileNode = templateAttrs.$$element = jqLite(compileNode),
|
||||||
directive,
|
directive,
|
||||||
|
|
@ -549,10 +550,10 @@ function $CompileProvider($provide) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (directiveValue = directive.scope) {
|
if (directiveValue = directive.scope) {
|
||||||
assertNoDuplicate('isolated scope', newIsolatedScopeDirective, directive, $compileNode);
|
assertNoDuplicate('isolated scope', newIsolateScopeDirective, directive, $compileNode);
|
||||||
if (isObject(directiveValue)) {
|
if (isObject(directiveValue)) {
|
||||||
safeAddClass($compileNode, 'ng-isolate-scope');
|
safeAddClass($compileNode, 'ng-isolate-scope');
|
||||||
newIsolatedScopeDirective = directive;
|
newIsolateScopeDirective = directive;
|
||||||
}
|
}
|
||||||
safeAddClass($compileNode, 'ng-scope');
|
safeAddClass($compileNode, 'ng-scope');
|
||||||
newScopeDirective = newScopeDirective || directive;
|
newScopeDirective = newScopeDirective || directive;
|
||||||
|
|
@ -706,12 +707,12 @@ function $CompileProvider($provide) {
|
||||||
}
|
}
|
||||||
$element = attrs.$$element;
|
$element = attrs.$$element;
|
||||||
|
|
||||||
if (newIsolatedScopeDirective) {
|
if (newIsolateScopeDirective) {
|
||||||
var LOCAL_REGEXP = /^\s*([@=&])\s*(\w*)\s*$/;
|
var LOCAL_REGEXP = /^\s*([@=&])\s*(\w*)\s*$/;
|
||||||
|
|
||||||
var parentScope = scope.$parent || scope;
|
var parentScope = scope.$parent || scope;
|
||||||
|
|
||||||
forEach(newIsolatedScopeDirective.scope, function(definiton, scopeName) {
|
forEach(newIsolateScopeDirective.scope, function(definiton, scopeName) {
|
||||||
var match = definiton.match(LOCAL_REGEXP) || [],
|
var match = definiton.match(LOCAL_REGEXP) || [],
|
||||||
attrName = match[2]|| scopeName,
|
attrName = match[2]|| scopeName,
|
||||||
mode = match[1], // @, =, or &
|
mode = match[1], // @, =, or &
|
||||||
|
|
@ -734,7 +735,7 @@ function $CompileProvider($provide) {
|
||||||
// reset the change, or we will throw this exception on every $digest
|
// reset the change, or we will throw this exception on every $digest
|
||||||
lastValue = scope[scopeName] = parentGet(parentScope);
|
lastValue = scope[scopeName] = parentGet(parentScope);
|
||||||
throw Error(NON_ASSIGNABLE_MODEL_EXPRESSION + attrs[attrName] +
|
throw Error(NON_ASSIGNABLE_MODEL_EXPRESSION + attrs[attrName] +
|
||||||
' (directive: ' + newIsolatedScopeDirective.name + ')');
|
' (directive: ' + newIsolateScopeDirective.name + ')');
|
||||||
};
|
};
|
||||||
lastValue = scope[scopeName] = parentGet(parentScope);
|
lastValue = scope[scopeName] = parentGet(parentScope);
|
||||||
scope.$watch(function parentValueWatch() {
|
scope.$watch(function parentValueWatch() {
|
||||||
|
|
@ -765,7 +766,7 @@ function $CompileProvider($provide) {
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
throw Error('Invalid isolate scope definition for directive ' +
|
throw Error('Invalid isolate scope definition for directive ' +
|
||||||
newIsolatedScopeDirective.name + ': ' + definiton);
|
newIsolateScopeDirective.name + ': ' + definiton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -991,7 +992,7 @@ function $CompileProvider($provide) {
|
||||||
if (interpolateFn) {
|
if (interpolateFn) {
|
||||||
directives.push({
|
directives.push({
|
||||||
priority: 0,
|
priority: 0,
|
||||||
compile: valueFn(function(scope, node) {
|
compile: valueFn(function textInterpolateLinkFn(scope, node) {
|
||||||
var parent = node.parent(),
|
var parent = node.parent(),
|
||||||
bindings = parent.data('$binding') || [];
|
bindings = parent.data('$binding') || [];
|
||||||
bindings.push(interpolateFn);
|
bindings.push(interpolateFn);
|
||||||
|
|
@ -1014,7 +1015,7 @@ function $CompileProvider($provide) {
|
||||||
|
|
||||||
directives.push({
|
directives.push({
|
||||||
priority: 100,
|
priority: 100,
|
||||||
compile: valueFn(function(scope, element, attr) {
|
compile: valueFn(function attrInterpolateLinkFn(scope, element, attr) {
|
||||||
var $$observers = (attr.$$observers || (attr.$$observers = {}));
|
var $$observers = (attr.$$observers || (attr.$$observers = {}));
|
||||||
|
|
||||||
if (name === 'class') {
|
if (name === 'class') {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue