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

ngSwitch directive leaks when inside transcluded content #1621

Closed
suedama1756 opened this issue Nov 28, 2012 · 5 comments
Closed

ngSwitch directive leaks when inside transcluded content #1621

suedama1756 opened this issue Nov 28, 2012 · 5 comments
Assignees

Comments

@suedama1756
Copy link

ngSwitch leaks when inside transcluded content. This is because it associates its data during the compile phase of the template.

element.data(NG_SWITCH, cases);

The template is then cloned for rendering, and as the clone doesn't include the jQuery expando property a leak occurs when the rendered content is removed.

@IgorMinar
Copy link
Contributor

can you please create a simple example on plnkr.co ?

@ghost ghost assigned IgorMinar Nov 28, 2012
@suedama1756
Copy link
Author

OK, will do. I've created a fix (which feels like a real workaround). The fundamental issue however is that any directive that uses the data() API during the compile phase can leak if it is then cloned within a transclude.

Busy this morning, but should be able to get samples out this afternoon (UK time)

@petebacondarwin
Copy link
Contributor

I am wondering whether ng-switch should be rebuilt to use directive controllers in any case, rather than inheritedData as it does right now?

danilsomsikov added a commit to danilsomsikov/angular.js that referenced this issue Jan 11, 2013
The leak can occur when ngSwich is used inside ngRepeat or any other
directive which does not attached transcluded content to DOM but clones
it.

Refactor ngSwitch to use controller instead of storing data on compile
node.

Closes angular#1621
@coli
Copy link

coli commented Jan 15, 2013

I think #1486 is related, just hit it today...

@mhevery mhevery closed this as completed Jan 18, 2013
IgorMinar pushed a commit to IgorMinar/angular.js that referenced this issue Jan 18, 2013
The leak can occur when ngSwich is used inside ngRepeat or any other
directive which is destroyed while its transcluded content (which
includes ngSwitch) is not attached to the DOM.

Refactor ngSwitch to use controller instead of storing data on compile
node. This means that we don't need to clean up the jq data cache.
Controller reference is released when the linking fn is released.

Closes angular#1621
IgorMinar pushed a commit that referenced this issue Jan 18, 2013
The leak can occur when ngSwich is used inside ngRepeat or any other
directive which is destroyed while its transcluded content (which
includes ngSwitch) is not attached to the DOM.

Refactor ngSwitch to use controller instead of storing data on compile
node. This means that we don't need to clean up the jq data cache.
Controller reference is released when the linking fn is released.

Closes #1621
IgorMinar pushed a commit that referenced this issue Jan 18, 2013
The leak can occur when ngSwich is used inside ngRepeat or any other
directive which is destroyed while its transcluded content (which
includes ngSwitch) is not attached to the DOM.

Refactor ngSwitch to use controller instead of storing data on compile
node. This means that we don't need to clean up the jq data cache.
Controller reference is released when the linking fn is released.

Closes #1621
@IgorMinar
Copy link
Contributor

this landed as a692dd8

please note that I changed the commit slightly. while the test and fix were correct the info about the cause of the leak in the commit message was not. the leak was caused by the switch element not being attached during the destruction of the parent dom (during which we do cleanup). it had nothing to do with cloning of dom nodes.

thanks for excellent work though!

jamessharp pushed a commit to jamessharp/angular.js that referenced this issue Jan 18, 2013
The leak can occur when ngSwich is used inside ngRepeat or any other
directive which is destroyed while its transcluded content (which
includes ngSwitch) is not attached to the DOM.

Refactor ngSwitch to use controller instead of storing data on compile
node. This means that we don't need to clean up the jq data cache.
Controller reference is released when the linking fn is released.

Closes angular#1621
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 a pull request may close this issue.

5 participants