Merge pull request #54 from google/tooltip-for-target

Check for existence of `for` target in MaterialTooltip
master
Addy Osmani 2015-03-18 13:24:59 +00:00
commit 814e0ca23e
1 changed files with 9 additions and 4 deletions

View File

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