Skip to content

Commit

Permalink
Add checking win.HTMLElement in isHTMLElement
Browse files Browse the repository at this point in the history
  • Loading branch information
anseki committed Sep 24, 2016
1 parent b7da107 commit af4f75e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/leader-line.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@

function isHTMLElement(element) {
var win, doc;
return !!(element && (doc = element.ownerDocument) && (win = doc.defaultView) &&
return !!(element && (doc = element.ownerDocument) && (win = doc.defaultView) && win.HTMLElement &&
element instanceof win.HTMLElement);
}
window.isHTMLElement = isHTMLElement; // [DEBUG/]
Expand Down
13 changes: 13 additions & 0 deletions test/spec/funcs.js
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,19 @@ describe('funcs', function() {
}
expect(isHTMLElement(element)).toBe(false);
});

it('other types:false', function() {
expect(isHTMLElement('a')).toBe(false);
expect(isHTMLElement(1)).toBe(false);
expect(isHTMLElement('')).toBe(false);
expect(isHTMLElement(0)).toBe(false);
expect(isHTMLElement(null)).toBe(false);
expect(isHTMLElement()).toBe(false);
expect(isHTMLElement({})).toBe(false);
expect(isHTMLElement(true)).toBe(false);
expect(isHTMLElement(window)).toBe(false);
expect(isHTMLElement(new Date())).toBe(false);
});
});

});

0 comments on commit af4f75e

Please sign in to comment.