From 79d955bec7c6a87a7a3fd93d42cc277972d78083 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Sat, 26 Sep 2015 06:20:19 +0600 Subject: [PATCH] fix non-deterministic V8 `Object.assign` property order sometimes it creates problems https://github.com/kangax/compat-table/commit/afa89886cdf8a954f5572b3c96f50122582c9a08#commitcomment-13449314 --- library/modules/$.assign.js | 14 +++++++++----- modules/$.assign.js | 14 +++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/library/modules/$.assign.js b/library/modules/$.assign.js index dcbd8bd58b09..41e42fcf286b 100644 --- a/library/modules/$.assign.js +++ b/library/modules/$.assign.js @@ -3,12 +3,16 @@ var toObject = require('./$.to-object') , IObject = require('./$.iobject') , enumKeys = require('./$.enum-keys'); -// should work with symbols +// should work with symbols and should have deterministic property order (V8 bug) module.exports = require('./$.fails')(function(){ - var O = {} - , S = Symbol(); - O[S] = 7; - return Object.assign({}, O)[S] != 7; + var a = Object.assign + , A = {} + , B = {} + , S = Symbol() + , K = 'abcdefghijklmnopqrst'; + A[S] = 7; + K.split('').forEach(function(k){ B[k] = k; }); + return a({}, A)[S] != 7 || Object.keys(a({}, B)).join('') != K; }) ? function assign(target, source){ // eslint-disable-line no-unused-vars var T = toObject(target) , l = arguments.length diff --git a/modules/$.assign.js b/modules/$.assign.js index dcbd8bd58b09..41e42fcf286b 100644 --- a/modules/$.assign.js +++ b/modules/$.assign.js @@ -3,12 +3,16 @@ var toObject = require('./$.to-object') , IObject = require('./$.iobject') , enumKeys = require('./$.enum-keys'); -// should work with symbols +// should work with symbols and should have deterministic property order (V8 bug) module.exports = require('./$.fails')(function(){ - var O = {} - , S = Symbol(); - O[S] = 7; - return Object.assign({}, O)[S] != 7; + var a = Object.assign + , A = {} + , B = {} + , S = Symbol() + , K = 'abcdefghijklmnopqrst'; + A[S] = 7; + K.split('').forEach(function(k){ B[k] = k; }); + return a({}, A)[S] != 7 || Object.keys(a({}, B)).join('') != K; }) ? function assign(target, source){ // eslint-disable-line no-unused-vars var T = toObject(target) , l = arguments.length