Skip to content

Commit beed2c3

Browse files
authored
fix(object mixin): Add polyfill Object.is for IE
1 parent 2a34407 commit beed2c3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/utils/object.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ if (typeof Object.assign != "function") {
3535
};
3636
}
3737

38+
// @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is#Polyfill
39+
if (!Object.is) {
40+
Object.is = function(x, y) {
41+
// SameValue algorithm
42+
if (x === y) { // Steps 1-5, 7-10
43+
// Steps 6.b-6.e: +0 != -0
44+
return x !== 0 || 1 / x === 1 / y;
45+
} else {
46+
// Step 6.a: NaN == NaN
47+
return x !== x && y !== y;
48+
}
49+
};
50+
}
51+
3852
export const assign = Object.assign;
3953
export const getOwnPropertyNames = Object.getOwnPropertyNames;
4054
export const keys = Object.keys;

0 commit comments

Comments
 (0)