Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

bug(tooltip): in dialog appended to body remains after closing dialog #710

Closed
tak-amboss opened this issue Jul 26, 2013 · 5 comments
Closed
Assignees
Milestone

Comments

@tak-amboss
Copy link

Hi,
a tooltip on a dialog close button remains after closing dialog if tooltip is appended to body:
http://jsfiddle.net/tak_aryelle/AAJZg/

@pkozlowski-opensource
Copy link
Member

Ha! Nice finding! I think we should be able to fix this by listening to the DOM $destroy event of the element on which a tooltip is placed. Thnx for reporting!

@pkozlowski-opensource
Copy link
Member

@ajoslin I think this is a valid bug in the current tooltip, I'm working on this one.

@ajoslin
Copy link
Contributor

ajoslin commented Jul 27, 2013

Ah woops, I thought it got merged already. my bad.

@pkozlowski-opensource
Copy link
Member

So this one is really nasty... It turns out that this is a bug in AngularJS, in the jQLite, to be more specific. In this routine:

function JQLiteUnbind(element, type, fn) {
  var events = JQLiteExpandoStore(element, 'events'),
      handle = JQLiteExpandoStore(element, 'handle');

  if (!handle) return; //no listeners registered

  if (isUndefined(type)) {
    forEach(events, function(eventHandler, type) {
      removeEventListenerFn(element, type, eventHandler);
      delete events[type];
    });
  } else {
    if (isUndefined(fn)) {
      removeEventListenerFn(element, type, events[type]);
      delete events[type];
    } else {
      arrayRemove(events[type], fn);
    }
  }
}

if you try to unbind an event that wasn't previously bound (and you pass in both type and fn) AngularJS will fail with Cannot read property 'indexOf' of undefined... jQuery behaves differently and it is more forgiving. Just including jQuery makes the issue go away. This is why our unit-test didn't catch it

I will try to submit a patch to AngularJS but in the meantime we need to find a way of patching it in our library...

@pkozlowski-opensource
Copy link
Member

So, the only remaining problem here is that the $dialog doesn't clean up after itself in therms of scopes :-( But I'm going to handle this in the $dialog rewrite: #441

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

No branches or pull requests

3 participants