Permalink
Browse files

fix: Remove usage of es2015 Array.prototype.includes (#589)

* remove all uses of es2015 Array.includes()
  • Loading branch information...
alexsasharegan authored and tmorehouse committed Jun 30, 2017
1 parent be5f834 commit b3fc0950f907ef9bbcac6a92c6be1d5aec2af0dd
@@ -18,6 +18,8 @@
<script>
import bLink from './link.vue';
import { props as linkProps } from '../mixins/link';
import arrayIncludes from '../utils/arrayIncludes';
const bLinkPropKeys = Object.keys(linkProps);
export default {
@@ -59,7 +61,7 @@ export default {
// so we can bind to the component
// for dynamic prop proxying
normalizedItem._linkProps = Object.keys(normalizedItem).reduce((memo, itemProp) => {
if (bLinkPropKeys.includes(itemProp)) {
if (arrayIncludes(bLinkPropKeys, itemProp)) {
memo[itemProp] = normalizedItem[itemProp];
}
@@ -20,8 +20,10 @@
<script>
import formMixin from '../mixins/form';
import formCheckBoxMixin from '../mixins/form-checkbox';
import arrayIncludes from '../utils/arrayIncludes';
import isArray from '../utils/isArray';
export default {
mixins: [formMixin, formCheckBoxMixin],
model: {
@@ -41,7 +43,7 @@ export default {
},
computed: {
isChecked() {
return this.checked.includes(this.value);
return arrayIncludes(this.checked, this.value);
}
},
methods: {
@@ -9,7 +9,8 @@

<script>
import bLink from './link.vue';
import { props as originalLinkProps, computed, omitLinkProps } from '../mixins/link'
import { props as originalLinkProps, computed, omitLinkProps } from '../mixins/link';
import arrayIncludes from '../utils/arrayIncludes';
// copy link props, but exclude defaults for 'href', 'to', & 'tag'
// to ensure proper component tag computation
const linkProps = Object.assign(omitLinkProps('href', 'to'), {
@@ -43,7 +44,7 @@ export default {
// this previously could return a string,
// coercing to a boolean for more consistent expected value
return !!(this.action || this.to || this.href || actionTags.includes(this.tag));
return !!(this.action || this.to || this.href || arrayIncludes(actionTags, this.tag));
},
listState() {
@@ -1,4 +1,5 @@
import warn from '../utils/warn';
import arrayIncludes from '../utils/arrayIncludes';
// Props compatible with vue-router
// https://github.com/vuejs/vue-router/blob/dev/src/components/link.js
export const props = {
@@ -151,7 +152,7 @@ export default {

export function pickLinkProps(...propsToPick) {
return Object.keys(props).reduce((memo, prop) => {
if (propsToPick.includes(prop)) {
if (arrayIncludes(propsToPick, prop)) {
memo[prop] = props[prop];
}

@@ -161,7 +162,7 @@ export function pickLinkProps(...propsToPick) {

export function omitLinkProps(...propsToOmit) {
return Object.keys(props).reduce((memo, prop) => {
if (!propsToOmit.includes(prop)) {
if (!arrayIncludes(propsToOmit, prop)) {
memo[prop] = props[prop];
}

@@ -0,0 +1,3 @@
export default function arrayIncludes(array, value) {
return array.indexOf(value) !== -1
}

0 comments on commit b3fc095

Please sign in to comment.