From d3af3dc83d87810c4fa447bb686cae21db44167f Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 9 Nov 2016 12:14:15 -0800 Subject: [PATCH] Use object.entries and object.assign for older environments --- package.json | 1 + src/Utils.js | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3c0b32d2b..5ca08cacf 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "lodash": "^4.16.4", "object-is": "^1.0.1", "object.assign": "^4.0.4", + "object.entries": "^1.0.3", "object.values": "^1.0.3", "uuid": "^2.0.3" }, diff --git a/src/Utils.js b/src/Utils.js index 81e0b96d2..a09439268 100644 --- a/src/Utils.js +++ b/src/Utils.js @@ -3,6 +3,8 @@ import isEqual from 'lodash/isEqual'; import React from 'react'; import is from 'object-is'; import uuid from 'uuid'; +import entries from 'object.entries'; +import assign from 'object.assign'; import functionName from 'function.prototype.name'; import { isDOMComponent, @@ -175,7 +177,7 @@ export function splitSelector(selector) { // step 1: make a map of all quoted strings with a uuid const quotedSegments = selector.split(/[^" ]+|("[^"]*")|.*/g) .filter(Boolean) - .reduce((obj, match) => ({ ...obj, [match]: uuid.v4() }), {}); + .reduce((obj, match) => assign({}, obj, { [match]: uuid.v4() }), {}); return selector // step 2: replace all quoted strings with the uuid, so we don't have to properly parse them @@ -185,7 +187,7 @@ export function splitSelector(selector) { // step 4: restore the quoted strings by swapping back the uuid's for the original segments .map((selectorSegment) => { let restoredSegment = selectorSegment; - Object.entries(quotedSegments).forEach(([k, v]) => { + entries(quotedSegments).forEach(([k, v]) => { restoredSegment = restoredSegment.replace(v, k); }); return restoredSegment;