Skip to content
Myr

Added polyfill for Object.is, fixes #77

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Michel Weststrate · committed by Michel Weststrate · parent 452e755 · Browse files · 3 files+15 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+15 added−4 removed

  • other:+15 added−4 removed

3 files+15 added−4 removed

modified:src/common.js+9 added
modified:src/es5.js+4 added-3 removed
1"use strict"2// @ts-check34import {5 is,6 isProxyable,7 isProxy,8 freeze,9 PROXY_STATE,
36 unmodified lines
4647function set(state, prop, value) {48 assertUnfinished(state)49 if (!state.modified) {49 if (Object.is(source(state)[prop], value)) return50 if (is(source(state)[prop], value)) return51 markChanged(state)52 prepareCopy(state)53 }54 state.copy[prop] = value
133 unmodified lines
188}189190function shallowEqual(objA, objB) {191 //From: https://github.com/facebook/fbjs/blob/c69904a511b900266935168223063dd8772dfc40/packages/fbjs/src/core/shallowEqual.js191 if (Object.is(objA, objB)) return true192 if (is(objA, objB)) return true193 if (194 typeof objA !== "object" ||195 objA === null ||196 typeof objB !== "object" ||
6 unmodified lines
203 if (keysA.length !== keysB.length) return false204 for (let i = 0; i < keysA.length; i++) {205 if (206 !hasOwnProperty.call(objB, keysA[i]) ||206 !Object.is(objA[keysA[i]], objB[keysA[i]])207 !is(objA[keysA[i]], objB[keysA[i]])208 ) {209 return false210 }211 }
10 unmodified lines
modified:src/proxy.js+2 added-1 removed
1"use strict"2// @ts-check34import {5 is,6 isProxyable,7 isProxy,8 freeze,9 PROXY_STATE,
63 unmodified lines
7374function set(state, prop, value) {75 if (!state.modified) {76 if (76 (prop in state.base && Object.is(state.base[prop], value)) ||77 (prop in state.base && is(state.base[prop], value)) ||78 (prop in state.proxies && state.proxies[prop] === value)79 )80 return true81 markChanged(state)
81 unmodified lines