Skip to content

Commit

Permalink
Use slice instead of substr for suffix/prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Dail committed Sep 29, 2017
1 parent f1943b0 commit c64dfe0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/enzyme/src/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ function matchAttributeSelector(node, token) {
* [type^="image"] matches type="imageobject"
*/
case PREFIX_ATTRIBUTE_OPERATOR:
return value === '' ? false : nodePropValue.substr(0, value.length) === value;
return value === '' ? false : nodePropValue.slice(0, value.length) === value;
/**
* 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"
*/
case SUFFIX_ATTRIBUTE_OPERATOR:
return value === '' ? false : nodePropValue.substr(-value.length) === value;
return value === '' ? false : nodePropValue.slice(-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 c64dfe0

Please sign in to comment.