-
Notifications
You must be signed in to change notification settings - Fork 27.5k
ngSwitch directive leaks when inside transcluded content #1621
Comments
can you please create a simple example on plnkr.co ? |
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) |
I am wondering whether ng-switch should be rebuilt to use directive controllers in any case, rather than inheritedData as it does right now? |
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
I think #1486 is related, just hit it today... |
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
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
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
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! |
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
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.
The text was updated successfully, but these errors were encountered: