mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-06-18 12:14:04 +08:00
fix($compile): reference correct directive name in ctreq error
Previously, ctreq would possibly reference the incorrect directive name, due to relying on a directiveName living outside of the closure which throws the exception, which can change before the call is ever made. This change saves the current value of directiveName as a property of the link function, which prevents this from occurring. Closes #7062 Closes #7067
This commit is contained in:
@@ -1341,6 +1341,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
if (pre) {
|
||||
if (attrStart) pre = groupElementsLinkFnWrapper(pre, attrStart, attrEnd);
|
||||
pre.require = directive.require;
|
||||
pre.directiveName = directiveName;
|
||||
if (newIsolateScopeDirective === directive || directive.$$isolateScope) {
|
||||
pre = cloneAndAnnotateFn(pre, {isolateScope: true});
|
||||
}
|
||||
@@ -1349,6 +1350,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
if (post) {
|
||||
if (attrStart) post = groupElementsLinkFnWrapper(post, attrStart, attrEnd);
|
||||
post.require = directive.require;
|
||||
post.directiveName = directiveName;
|
||||
if (newIsolateScopeDirective === directive || directive.$$isolateScope) {
|
||||
post = cloneAndAnnotateFn(post, {isolateScope: true});
|
||||
}
|
||||
@@ -1357,7 +1359,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
}
|
||||
|
||||
|
||||
function getControllers(require, $element, elementControllers) {
|
||||
function getControllers(directiveName, require, $element, elementControllers) {
|
||||
var value, retrievalMethod = 'data', optional = false;
|
||||
if (isString(require)) {
|
||||
while((value = require.charAt(0)) == '^' || value == '?') {
|
||||
@@ -1383,7 +1385,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
} else if (isArray(require)) {
|
||||
value = [];
|
||||
forEach(require, function(require) {
|
||||
value.push(getControllers(require, $element, elementControllers));
|
||||
value.push(getControllers(directiveName, require, $element, elementControllers));
|
||||
});
|
||||
}
|
||||
return value;
|
||||
@@ -1526,7 +1528,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
try {
|
||||
linkFn = preLinkFns[i];
|
||||
linkFn(linkFn.isolateScope ? isolateScope : scope, $element, attrs,
|
||||
linkFn.require && getControllers(linkFn.require, $element, elementControllers), transcludeFn);
|
||||
linkFn.require && getControllers(linkFn.directiveName, linkFn.require, $element, elementControllers), transcludeFn);
|
||||
} catch (e) {
|
||||
$exceptionHandler(e, startingTag($element));
|
||||
}
|
||||
@@ -1546,7 +1548,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
try {
|
||||
linkFn = postLinkFns[i];
|
||||
linkFn(linkFn.isolateScope ? isolateScope : scope, $element, attrs,
|
||||
linkFn.require && getControllers(linkFn.require, $element, elementControllers), transcludeFn);
|
||||
linkFn.require && getControllers(linkFn.directiveName, linkFn.require, $element, elementControllers), transcludeFn);
|
||||
} catch (e) {
|
||||
$exceptionHandler(e, startingTag($element));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user