Skip to content

Commit

Permalink
[Representation] Handle undefined scope
Browse files Browse the repository at this point in the history
element.scope() may be undefined when wiring in the info
gesture, so check for that.

That this is sometimes undefined appears to be a consequence
of changes to mct-representation, but which changes influence
this are unclear. In any event, it appears that this cannot
be relied-upon per angular/angular.js#9515
  • Loading branch information
VWoeltjen committed Oct 28, 2015
1 parent 0404303 commit ea9f607
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions platform/commonUI/inspect/src/gestures/InfoGesture.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ define(
self.trackPosition(event);
};

// Also make sure we dismiss bubble if representation is destroyed
// before the mouse actually leaves it
this.scopeOff =
element.scope().$on('$destroy', this.hideBubbleCallback);

this.element = element;
this.$timeout = $timeout;
this.infoService = infoService;
Expand Down Expand Up @@ -131,6 +126,13 @@ define(
this.pendingBubble = this.$timeout(displayBubble, this.delay);

this.element.on('mouseleave', this.hideBubbleCallback);

// Also make sure we dismiss bubble if representation is destroyed
// before the mouse actually leaves it
this.scopeOff =
this.element.scope() &&
this.element.scope().$on('$destroy', this.hideBubbleCallback);

};


Expand All @@ -143,7 +145,9 @@ define(
this.hideBubble();
// ...and detach listeners
this.element.off('mouseenter', this.showBubbleCallback);
this.scopeOff();
if (this.scopeOff) {
this.scopeOff();
}
};

return InfoGesture;
Expand Down

0 comments on commit ea9f607

Please sign in to comment.