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

Order of directives link function reversed in 1.2.rc1 #3656

Closed
barakka opened this issue Aug 19, 2013 · 2 comments
Closed

Order of directives link function reversed in 1.2.rc1 #3656

barakka opened this issue Aug 19, 2013 · 2 comments

Comments

@barakka
Copy link

barakka commented Aug 19, 2013

Hello,

i've been porting my application to 1.2.rc1 and I've noticed that the behavior of the link function on directives using ng-transclude has changed, and it is now reversed (parent are linked before children). The real problem, however, is that the DOM element received in parent link function is empty, which makes any DOM manipulation useless (like applying a jQuery plugin).

I've created two fiddles: the first uses 1.1.5 (http://jsfiddle.net/NXwu5/), and in the console you can see that the child link function is called first and the parent second, and in both cases the element received is complete (its children property is non empty); the second uses 1.2.rc1 (http://jsfiddle.net/PkTLj/1/), and in this case the parent link function is called before the child and, more importantly, the element received is empty.

I've looked at the changelog and to previous bug reports, and if fact one of the changes seems to be related to this problem ("always instantiate controllers in parent->child order (45f9f62, #2738)"). Moreover, an older bug seems also to be related (Issue #1567), although changing the replace attribute does not seems to fix the issue.

So far I've been able to solve the problem by manually transcluding (http://jsfiddle.net/PkTLj/4/ ): the order of invocation is still reversed but, as i'm transcluding myself, I'm able to activate my jQuery plugin when the element children have been added. Notice, however, that the element is still incomplete: as the order of the link functions is still reverted, I get access only to the parent children, not to the grandchildren (which, my plugin fortunately does not need).

I don't know if this was intended, or if I'm not understanding correctly the transclusion thing, but I believe the new behavior breaks the promise that the link function is fine for DOM manipulation (i've tried using pre- and post- linking functions with the same result).

Any idea on what I might be doing wrong?

Thanks,
R.

@aeby
Copy link
Contributor

aeby commented Aug 19, 2013

Similar to #3558

@ghost ghost assigned IgorMinar Sep 25, 2013
@IgorMinar
Copy link
Contributor

closing as dupe of #3558

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants