Skip to content

Commit

Permalink
Trying to fix the build
Browse files Browse the repository at this point in the history
  • Loading branch information
sunesimonsen committed Feb 25, 2019
1 parent cab5b93 commit 9741b3e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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++;
Expand All @@ -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++;
Expand Down

0 comments on commit 9741b3e

Please sign in to comment.