From 3f2bce732b279b169f76a7fedcc02d70465817b8 Mon Sep 17 00:00:00 2001 From: Jess Date: Wed, 18 Sep 2019 12:31:30 -0400 Subject: [PATCH] IE11 Compatibility: Replacing String.includes usages with String.indexOf --- src/services/paths.js | 4 ++-- src/services/resolver.js | 6 +++--- src/services/store.js | 2 +- src/services/wildcards.js | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/services/paths.js b/src/services/paths.js index c1bd584..6227ae6 100644 --- a/src/services/paths.js +++ b/src/services/paths.js @@ -19,7 +19,7 @@ import { isObject } from '../utils/object' */ export function makePaths (path, props, fnResolver) { // handle wildcards - if (typeof path === 'string' && path.includes('*')) { + if (typeof path === 'string' && path.indexOf('*') > -1) { return makePathsHash(fnResolver(path)) } @@ -68,7 +68,7 @@ export function makePaths (path, props, fnResolver) { */ export function makePath (path, target = '') { path = path.replace(/\/+$/, '') - const value = path.includes('@') + const value = path.indexOf('@') > -1 ? path + '.' + target : path + '/' + target return value diff --git a/src/services/resolver.js b/src/services/resolver.js index 15372de..808bf3b 100644 --- a/src/services/resolver.js +++ b/src/services/resolver.js @@ -108,7 +108,7 @@ export function resolve (store, path) { // parent let modPath, trgName - if (statePath.includes('/')) { + if (statePath.indexOf('/') > -1) { const keys = statePath.split('/') trgName = keys.pop() modPath = keys.join('/') @@ -128,7 +128,7 @@ export function resolve (store, path) { module: modPath, target: statePath, name: trgName.replace('!', ''), - isDynamic: path.includes(':'), + isDynamic: path.indexOf(':') > -1, /** * Returns properties about the targeted member @@ -167,7 +167,7 @@ export function resolve (store, path) { */ export function getError(path, resolver, aName, a, bName, b) { let error = `[Vuex Pathify] Unable to map path '${path}':` - if (path.includes('!')) { + if (path.indexOf('!') > -1) { error += ` - Did not find ${aName} or ${bName} named '${resolver.name}' on ${resolver.module ? `module '${resolver.module}'`: 'root store'}` } diff --git a/src/services/store.js b/src/services/store.js index 9368710..c6dd576 100644 --- a/src/services/store.js +++ b/src/services/store.js @@ -104,7 +104,7 @@ export function makeGetter (store, path, stateOnly) { * @returns {*} */ function getValueIfEnabled(expr, source, path) { - if (!options.deep && expr.includes('@')) { + if (!options.deep && expr.indexOf('@') > -1) { console.error(`[Vuex Pathify] Unable to access sub-property for path '${expr}': - Set option 'deep' to 1 to allow it`) return diff --git a/src/services/wildcards.js b/src/services/wildcards.js index 67c88bc..f52a911 100644 --- a/src/services/wildcards.js +++ b/src/services/wildcards.js @@ -116,7 +116,7 @@ export function resolveHandlers (path, hash) { */ export function init (path, state) { // only wildcards in final path segment are supported - if (path.includes('*') && /\*.*[/@.]/.test(path)) { + if (path.indexOf('*') > -1 && /\*.*[/@.]/.test(path)) { console.error(`[Vuex Pathify] Invalid wildcard placement for path '${path}': - Wildcards may only be used in the last segment of a path`) return false