Skip to content

Commit

Permalink
[Refactor] use slice instead of deprecated substr or substring
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Nov 12, 2016
1 parent e9ede3e commit 1880850
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/MountedTraversal.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ export function buildInstPredicate(selector) {

switch (selectorType(selector)) {
case SELECTOR.CLASS_TYPE:
return inst => hasClassName(inst, selector.substr(1));
return inst => hasClassName(inst, selector.slice(1));
case SELECTOR.ID_TYPE:
return inst => instHasId(inst, selector.substr(1));
return inst => instHasId(inst, selector.slice(1));
case SELECTOR.PROP_TYPE: {
const propKey = selector.split(/\[([a-zA-Z][a-zA-Z_\d\-:]*?)(=|])/)[1];
const propValue = selector.split(/=(.*?)]/)[1];
Expand Down
4 changes: 2 additions & 2 deletions src/ShallowTraversal.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ export function buildPredicate(selector) {

switch (selectorType(selector)) {
case SELECTOR.CLASS_TYPE:
return node => hasClassName(node, selector.substr(1));
return node => hasClassName(node, selector.slice(1));

case SELECTOR.ID_TYPE:
return node => nodeHasId(node, selector.substr(1));
return node => nodeHasId(node, selector.slice(1));

case SELECTOR.PROP_TYPE: {
const propKey = selector.split(/\[([a-zA-Z-]*?)(=|])/)[1];
Expand Down
2 changes: 1 addition & 1 deletion src/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export function isReactElementAlike(arg) {
// 'mouseEnter' => 'onMouseEnter'
export function propFromEvent(event) {
const nativeEvent = mapNativeEventNames(event);
return `on${nativeEvent[0].toUpperCase()}${nativeEvent.substring(1)}`;
return `on${nativeEvent[0].toUpperCase()}${nativeEvent.slice(1)}`;
}

export function withSetStateAllowed(fn) {
Expand Down

0 comments on commit 1880850

Please sign in to comment.