Complete existence check before using handler

This commit is contained in:
Thomas Neirynck 2016-10-31 10:11:40 -04:00
parent 0de553d37b
commit 6fad2be793
3 changed files with 9 additions and 15 deletions

View file

@ -101,7 +101,9 @@ export default function DispatchClass(Private, config) {
const isClickable = this.listenerCount('click') > 0;
const addEvent = this.addEvent;
const $el = this.handler.el;
this.handler.highlight = self.highlight;
if (!this.handler.highlight) {
this.handler.highlight = self.highlight;
}
function hover(d, i) {
// Add pointer if item is clickable
@ -125,7 +127,9 @@ export default function DispatchClass(Private, config) {
const self = this;
const addEvent = this.addEvent;
const $el = this.handler.el;
this.handler.unHighlight = self.unHighlight;
if (!this.handler.unHighlight) {
this.handler.unHighlight = self.unHighlight;
}
function mouseout() {
self.handler.unHighlight.call(this, $el);

View file

@ -76,19 +76,7 @@ export default function HandlerBaseClass(Private) {
* @returns {*}
*/
this.disable = this.chartEventProxyToggle('off');
}
/**
* Clients expect the Handler-type to have a highlight/unhighlight functions. The default implementation is a noop.
* Specific implementations are free to override this.
*/
highlight() {
}
unHighlight() {
}
/**
* Validates whether data is actually present in the data object
* used to render the Vis. Throws a no results error if data is not

View file

@ -29,7 +29,9 @@ uiModules.get('kibana')
$scope.highlight = function (event) {
let el = event.currentTarget;
let handler = $scope.renderbot.vislibVis.handler;
if (!handler) {
//there is no guarantee that a Chart will set the highlight-function on its handler
if (!handler || typeof handler.highlight !== 'function') {
return;
}
handler.highlight.call(el, handler.el);