From 9741b3e1c7ea79eb5bd47d09c510ad222ce7b76c Mon Sep 17 00:00:00 2001 From: Sune Simonsen Date: Mon, 25 Feb 2019 22:03:12 +0100 Subject: [PATCH] Trying to fix the build --- src/index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index aff92dfa..9bbfba8f 100644 --- a/src/index.js +++ b/src/index.js @@ -1486,8 +1486,9 @@ module.exports = { } if (typeof element.hasAttribute === 'function') { - const { class: className, style, ...attributes } = - spec.attributes || {}; + const attributes = spec.attributes || {}; + const className = attributes['class']; + const style = attributes.style; if (className && element.hasAttribute('class')) { if (typeof className === 'string') { @@ -1527,9 +1528,14 @@ module.exports = { }); } + const specialAttributes = ['style', 'class']; const ids = ['id', 'data-test-id', 'data-testid']; Object.keys(attributes).forEach(attributeName => { + if (specialAttributes.indexOf(attributeName) !== -1) { + return; // skip + } + if (element.hasAttribute(attributeName)) { if (typeof attributes[attributeName] === 'boolean') { score++; @@ -1538,7 +1544,7 @@ module.exports = { if ( element.getAttribute(attributeName) === attributes[attributeName] ) { - score += ids.includes(attributeName) ? 100 : 1; + score += ids.indexOf(attributeName) !== -1 ? 100 : 1; } } else if (!attributes[attributeName]) { score++;