aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIgor Minar2013-10-01 07:55:47 -0700
committerIgor Minar2013-10-03 22:23:37 -0700
commit31f190d4d53921d32253ba80d9ebe57d6c1de82b (patch)
tree147f87340b3ca3cd41d31537f876642c70bd133f /src
parentfe2145016cb057c92f9f01b32c58b4d7259eb6ee (diff)
downloadangular.js-31f190d4d53921d32253ba80d9ebe57d6c1de82b.tar.bz2
fix($compile): fix (reverse) directive postLink fn execution order
previously the compile/link fns executed in this order controlled via priority: - CompilePriorityHigh, CompilePriorityMedium, CompilePriorityLow - PreLinkPriorityHigh, PreLinkPriorityMedium, PreLinkPriorityLow - link children - PostLinkPriorityHigh, PostLinkPriorityMedium, PostLinkPriorityLow This was changed to: - CompilePriorityHigh, CompilePriorityMedium, CompilePriorityLow - PreLinkPriorityHigh, PreLinkPriorityMedium, PreLinkPriorityLow - link children - PostLinkPriorityLow, PostLinkPriorityMedium , PostLinkPriorityHigh Using this order the child transclusion directive that gets replaced onto the current element get executed correctly (see issue #3558), and more generally, the order of execution of post linking function makes more sense. The incorrect order was an oversight that has gone unnoticed for many suns and moons. (FYI: postLink functions are the default linking functions) BREAKING CHANGE: the order of postLink fn is now mirror opposite of the order in which corresponding preLinking and compile functions execute. Very few directives in practice rely on order of postLinking function (unlike on the order of compile functions), so in the rare case of this change affecting an existing directive, it might be necessary to convert it to a preLinking function or give it negative priority (look at the diff of this commit to see how an internal attribute interpolation directive was adjusted). Closes #3558
Diffstat (limited to 'src')
-rw-r--r--src/ng/compile.js5
-rw-r--r--src/ng/directive/input.js2
2 files changed, 4 insertions, 3 deletions
diff --git a/src/ng/compile.js b/src/ng/compile.js
index a4e44f01..fce6f34e 100644
--- a/src/ng/compile.js
+++ b/src/ng/compile.js
@@ -1095,7 +1095,7 @@ function $CompileProvider($provide) {
childLinkFn && childLinkFn(scope, linkNode.childNodes, undefined, boundTranscludeFn);
// POSTLINKING
- for(i = 0, ii = postLinkFns.length; i < ii; i++) {
+ for(i = postLinkFns.length - 1; i >= 0; i--) {
try {
linkFn = postLinkFns[i];
linkFn(scope, $element, attrs,
@@ -1328,7 +1328,7 @@ function $CompileProvider($provide) {
}
directives.push({
- priority: 100,
+ priority: -100,
compile: valueFn(function attrInterpolateLinkFn(scope, element, attr) {
var $$observers = (attr.$$observers || (attr.$$observers = {}));
@@ -1346,6 +1346,7 @@ function $CompileProvider($provide) {
// register any observers
if (!interpolateFn) return;
+ // TODO(i): this should likely be attr.$set(name, iterpolateFn(scope) so that we reset the actual attr value
attr[name] = interpolateFn(scope);
($$observers[name] || ($$observers[name] = [])).$$inter = true;
(attr.$$observers && attr.$$observers[name].$$scope || scope).
diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js
index fa953419..ee613a6e 100644
--- a/src/ng/directive/input.js
+++ b/src/ng/directive/input.js
@@ -958,7 +958,7 @@ var VALID_CLASS = 'ng-valid',
</file>
* </example>
*
- *
+ *
*/
var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$parse',
function($scope, $exceptionHandler, $attr, $element, $parse) {