Check for existance of `for` target in MaterialTooltip

master
Alexander Surma 2015-03-17 16:17:47 +00:00
parent a04efdbe4f
commit 15ca247d53
1 changed files with 9 additions and 4 deletions

View File

@ -72,11 +72,16 @@ MaterialTooltip.prototype.init = function() {
if (this.element_) {
var forElId = this.element_.getAttribute('for');
var forEl = document.getElementById(forElId);
forEl;
if(forElId) {
forEl = document.getElementById(forElId);
}
forEl.addEventListener('mouseenter', this.handleMouseEnter_.bind(this),
false);
forEl.addEventListener('mouseleave', this.handleMouseLeave_.bind(this));
if(forEl) {
forEl.addEventListener('mouseenter', this.handleMouseEnter_.bind(this),
false);
forEl.addEventListener('mouseleave', this.handleMouseLeave_.bind(this));
}
}
};