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

fix($compile): allow compile data to be GCed after a non-clone linking #13422

Merged
merged 1 commit into from
Aug 30, 2016

Conversation

jbedard
Copy link
Collaborator

@jbedard jbedard commented Dec 1, 2015

This does two things:

  • nulls out some data when a non-cloning transclude link completes to allow mainly the boundTranscludeFn func/closure $compileNodes/compositeLinkFn to be GCed
  • throws if that transclude link is executed again since that would either re-link the same element or clone the linked element

@Narretz
Copy link
Contributor

Narretz commented Dec 1, 2015

I believe this has the potential to break some people's apps, simply because it's not obvious how you are supposed to use $transclude. But it's good for 1.6.x, with a BC notice.

@Narretz Narretz added this to the 1.6.x milestone Dec 1, 2015
@petebacondarwin petebacondarwin modified the milestones: 1.6.x, 1.4.9 Dec 1, 2015
@jbedard
Copy link
Collaborator Author

jbedard commented Dec 2, 2015

Anything that breaks was probably already broken, although this might make it more broken (by throwing).

Which makes me think this should also be done on link functions, not only on the transclude functions...

@jbedard
Copy link
Collaborator Author

jbedard commented Dec 30, 2015

The transclusion slot stuff made this a bit more complicated so I've simplified it to only null out the link function data (not transclusion function data - which really just wraps the link function data). This is probably a better first step anyway...

@petebacondarwin petebacondarwin modified the milestones: 1.4.9, 1.4.10 Jan 21, 2016
@petebacondarwin petebacondarwin modified the milestones: 1.4.10, 1.5.1 Jan 28, 2016
@gkalpak gkalpak modified the milestones: 1.5.1, 1.5.2 Mar 16, 2016
@matsko matsko modified the milestones: 1.5.2, 1.5.3 Mar 18, 2016
@petebacondarwin petebacondarwin removed this from the 1.5.5 milestone Apr 18, 2016
@Narretz
Copy link
Contributor

Narretz commented May 25, 2016

I think we can try it for 1.6. We should probably keep a list of possibly problematic commits for when we will snyc 1.6 to g3 in the future.
Before we merge it, we need an error doc for the multilink error with description and examples what can cause this.

@Narretz Narretz modified the milestones: 1.5.6, 1.5.7 May 27, 2016
@jbedard
Copy link
Collaborator Author

jbedard commented Jun 1, 2016

I've added an error doc.

@gkalpak gkalpak modified the milestones: 1.5.7, 1.5.8 Jun 15, 2016
@petebacondarwin petebacondarwin modified the milestones: 1.5.8, 1.5.9 Jul 22, 2016
@jbedard
Copy link
Collaborator Author

jbedard commented Aug 27, 2016

1.6? 😁

@jbedard jbedard changed the title refactor($compile): allow transclude data to be GCed after a non-cloning transclusion refactor($compile): allow compile data to be GCed after a non-clone linking Aug 27, 2016
@Narretz
Copy link
Contributor

Narretz commented Aug 28, 2016

Even though it's unlikely that this is going to break apps, I feel like we should mark this as "fix", just so that it shows up in the changelog, and when people have their app broken, they might see what's causing it.

@Narretz Narretz modified the milestones: 1.6.x, 1.5.9 Aug 28, 2016
Previously the following would invoke the elemnet link function multiple
times, causing unknown and potentially buggy results:

    var link = $compile(html);
    link(scope);
    link(scope);

This was always unsupported. Now this throws a multilink error.
@jbedard jbedard changed the title refactor($compile): allow compile data to be GCed after a non-clone linking fix($compile): allow compile data to be GCed after a non-clone linking Aug 29, 2016
@jbedard
Copy link
Collaborator Author

jbedard commented Aug 29, 2016

I've updated the commit message

@Narretz Narretz merged commit 1e1fbc7 into angular:master Aug 30, 2016
@Narretz
Copy link
Contributor

Narretz commented Aug 30, 2016

Finally landed! Thanks for your preserverance jbedard. Due to how easy it is to make this mistake, I'll leave it in 1.6 only (for now). Especially since with some simple directives (such as interpolation), you won't notice any difference in behavior when linking multiple times.

@jbedard
Copy link
Collaborator Author

jbedard commented Sep 1, 2016

I think just 1.6 is best unless there's a strong reason to put it into 1.5. This can be considered a BC for those using $compile incorrectly...

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

Successfully merging this pull request may close these issues.

6 participants