From bfd016bde12f996ab0c9d5f57ff0173388091eec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Tue, 8 May 2018 16:10:28 +0200 Subject: [PATCH] Check for `el.hasAttribute` before invoking This is called on nodes while traversing up the DOM, and there is no guarantee that a node is an Element node and that it will implement the `hasAttribute` function. --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 000293f..4c567da 100644 --- a/index.js +++ b/index.js @@ -192,7 +192,7 @@ function inspect(element) { function selectors(element) { const components = [element.nodeName.toLowerCase()] if (element.id) components.push(`#${element.id}`) - if (element.hasAttribute('class')) { + if (typeof element.hasAttribute === 'function' && element.hasAttribute('class')) { for (const name of element.getAttribute('class').split(/\s+/)) { if (name.match(/^js-/)) components.push(`.${name}`) }