Skip to content

Commit

Permalink
Fix suffix attribute selector logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Dail authored and ljharb committed Sep 26, 2017
1 parent de3069d commit 11663db
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/enzyme/src/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ function matchAttributeSelector(node, token) {
// Only the exact value operator ("=") can match non-strings
if (typeof nodePropValue !== 'string' || typeof value !== 'string') {
if (operator !== EXACT_ATTRIBUTE_OPERATOR) {
return false;
}
return false;
}
}
switch (operator) {
/**
Expand Down Expand Up @@ -111,10 +111,10 @@ function matchAttributeSelector(node, token) {
* Represents an element with the att attribute whose value ends with the suffix value.
* If the value is the empty string then the selector does not represent anything.
* @example
* [type^="image"] matches type="imageobject"
* [type$="image"] matches type="imageobject"
*/
case SUFFIX_ATTRIBUTE_OPERATOR:
return value === '' ? false : nodePropValue.substr(0, -value.length) === value;
return value === '' ? false : nodePropValue.substr(-value.length) === value;
/**
* Represents an element with the att attribute whose value contains at least one
* instance of the value. If value is the empty string then the
Expand Down

0 comments on commit 11663db

Please sign in to comment.