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

replace directive $element still references replaced DOM element #7900

Closed
jbedard opened this issue Jun 18, 2014 · 6 comments
Closed

replace directive $element still references replaced DOM element #7900

jbedard opened this issue Jun 18, 2014 · 6 comments

Comments

@jbedard
Copy link
Collaborator

jbedard commented Jun 18, 2014

...if using jQuery instead of jqLite because the jQuery $element still references the replaced DOM element as the context. This only occurs if the element is replaced and not cloned since cloning creates a new jQuery object instead of just modifying the compiled $element. (http://plnkr.co/edit/vGwzc1FGt127pQ1wbKNT?p=preview)

This isn't huge, and isn't really a memory leak because it will get destroyed along with the $element, but it would be nice if the replaced DOM was cleaned up. I think this can be fixed in the $compile replaceWith helper by properly clearing the jQuery context...

edit: I originally had something about replace & -start/end in here too but that seems unrelated.

@Narretz Narretz self-assigned this Jun 20, 2014
@Narretz Narretz added this to the Backlog milestone Jun 20, 2014
@Narretz Narretz removed their assignment Jun 20, 2014
@mgol
Copy link
Member

mgol commented Aug 1, 2014

The next Angular 1.3.0 beta will support jQuery 2.1 (and will not officially support older versions though they should work). The relevant commit: 9e7cb3c

The beta should be released in about a week. Before that happens, you can check if the issue still exists by trying the snapshot Angular version: https://code.angularjs.org/snapshot/angular.js

Don't use it in production, though, wait for a proper release.

@jbedard
Copy link
Collaborator Author

jbedard commented Aug 1, 2014

jQuery 2 hasn't changed .context so the issue will still exist. Here's an updated plunker using the angular snapshot and jQuery 2.1: http://plnkr.co/edit/A1DFKQqTqEKPR2NJpsIz?p=preview

@mgol
Copy link
Member

mgol commented Aug 7, 2014

Thanks, I'll look into it.

@mgol mgol modified the milestones: Backlog, 1.3.0-beta.18 Aug 7, 2014
@petebacondarwin
Copy link
Contributor

@mzgol - I am assuming that you are taking this one?

@mgol
Copy link
Member

mgol commented Aug 8, 2014

Yes, I'll get it merged soon.

@caitp
Copy link
Contributor

caitp commented Aug 8, 2014

@mzgol if you land the stuff you're confident is ready to go, I don't think the tree should be brittle now (could be wrong though!)

@jeffbcross jeffbcross assigned IgorMinar and unassigned mgol Aug 11, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.