Skip to content

Commit

Permalink
fix(utils.matches): fix attribute exists selector to match empty attr…
Browse files Browse the repository at this point in the history
…ibutes (#3669)

* fix(utils.matches): fix attribute exists selector to match empty attributes

* comments

* Update test/core/utils/matches.js

Co-authored-by: Wilco Fiers <[email protected]>

* Update test/core/utils/matches.js

Co-authored-by: Wilco Fiers <[email protected]>

Co-authored-by: Wilco Fiers <[email protected]>
  • Loading branch information
straker and WilcoFiers authored Sep 26, 2022
1 parent 3f3edd6 commit 4b768ea
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 69 deletions.
5 changes: 3 additions & 2 deletions lib/core/utils/matches.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function matchesAttributes(vNode, exp) {
!exp.attributes ||
exp.attributes.every(att => {
var nodeAtt = vNode.attr(att.key);
return nodeAtt !== null && (!att.value || att.test(nodeAtt));
return nodeAtt !== null && att.test(nodeAtt);
})
);
}
Expand Down Expand Up @@ -108,9 +108,10 @@ function convertAttributes(atts) {
return attributeValue !== value;
};
break;
// attribute existence
default:
test = value => {
return !!value;
return value !== null;
};
}

Expand Down
Loading

0 comments on commit 4b768ea

Please sign in to comment.