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

WIP fix($compile): don't instantiate controllers twice for element transclud... #4654

Closed
wants to merge 2 commits into from

Conversation

IgorMinar
Copy link
Contributor

...e directives

@mary-poppins
Copy link

Thanks for the PR!

  • Contributor signed CLA now or in the past
    • If you just signed, leave a comment here with your real name
  • PR's commit messages follow the commit message format

If you need to make changes to your pull request, you can update the commit with git commit --amend.
Then, update the pull request with git push -f.

Thanks again for your help!

@IgorMinar
Copy link
Contributor Author

still needs tests...

templateDirective: templateDirective,
// Don't pass in:
// - controllerDirectives - otherwise we'll create duplicates controllers
// - newIsolateScopeDirective - combining templates with element transclusion
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment is odd

@vojtajina
Copy link
Contributor

Still didn't look into it properly, but here are some quick comments:

  • now we don't check for multiple isolate scopes on the same element,
  • neither we check for duplicate controller names on the same element, right?

A few weeks ago, I changed the "templateUrl + replace" use case to only have one linkin function (nodeLinkFn). In theory I think we should do the same for "transclude element". At this point we have two - linking of all the directives "before" the transluding directive (all directives with higher priority) and then the rest on the translcluded element.

So I don't think this is the proper fix. However I say LGTM, because it's better to "forget to complain about multiple directives with isolate scope" that the current behavior (instantiating multiple controllers). I need more brain power to suggest something better.

@vojtajina
Copy link
Contributor

@IgorMinar Let's talk about this in person. Monday?

@IgorMinar
Copy link
Contributor Author

I don't think that there can be a single linking fn because with element transclusion we always deal with at least two nodes

1/ the original node that contained the element transclusion directive. this node got destroyed and was replaced with the comment
2/ the clone of the original node that was recompiled starting at priority lower than the element transclusion directive

so because of this, I believe that it's correct to have two linking fns.

also because of how this all works, it doesn't make sense to to use template or template with e;lement transctiolsion directive.

@IgorMinar IgorMinar closed this in 18ae985 Oct 28, 2013
jamesdaily pushed a commit to jamesdaily/angular.js that referenced this pull request Jan 27, 2014
…lude directives

This is a fix for regression introduced last week by faf5b98.

Closes angular#4654
jamesdaily pushed a commit to jamesdaily/angular.js that referenced this pull request Jan 27, 2014
…lude directives

This is a fix for regression introduced last week by faf5b98.

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

Successfully merging this pull request may close these issues.

3 participants