From b399a034e4eba02244d5df42fef3d9888ed8770d Mon Sep 17 00:00:00 2001 From: David Blurton Date: Tue, 12 Apr 2016 01:01:09 +0000 Subject: [PATCH 1/7] Don't try to make React elements immutable (#1) * Don't try to make React elements immutable * Extract test as function * Don't crash if Symbol isn't defined --- src/seamless-immutable.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/seamless-immutable.js b/src/seamless-immutable.js index 50104e4..a9aa672 100644 --- a/src/seamless-immutable.js +++ b/src/seamless-immutable.js @@ -470,9 +470,13 @@ return makeImmutable(obj, mutatingObjectMethods); } + + function isReactElement(obj) { + return obj.hasOwnProperty('$$typeof') && typeof Symbol === 'function' && obj.$$typeof === Symbol.for('react.element'); + } function Immutable(obj, options) { - if (isImmutable(obj)) { + if (isImmutable(obj) || isReactElement(obj)) { return obj; } else if (obj instanceof Array) { return makeImmutableArray(obj.slice()); From 5cfa7edc6968fb88126b25a1dbec8691eed5098c Mon Sep 17 00:00:00 2001 From: David Blurton Date: Tue, 12 Apr 2016 01:11:02 +0000 Subject: [PATCH 2/7] An object created with Object.create(null) doesn't have the method Object.hasOwnProperty --- src/seamless-immutable.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/seamless-immutable.js b/src/seamless-immutable.js index a9aa672..b608512 100644 --- a/src/seamless-immutable.js +++ b/src/seamless-immutable.js @@ -472,7 +472,10 @@ } function isReactElement(obj) { - return obj.hasOwnProperty('$$typeof') && typeof Symbol === 'function' && obj.$$typeof === Symbol.for('react.element'); + return obj.hasOwnProperty && + obj.hasOwnProperty('$$typeof') && + typeof Symbol === 'function' && + obj.$$typeof === Symbol.for('react.element'); } function Immutable(obj, options) { From 20efb23a38f49b2e2261d54e4187f73a81f34d87 Mon Sep 17 00:00:00 2001 From: David Blurton Date: Wed, 13 Apr 2016 08:54:59 +0000 Subject: [PATCH 3/7] Use definition of react element from React and support browsers that don't support Symbol --- seamless-immutable.development.js | 10 +++++++++- seamless-immutable.development.min.js | 2 +- seamless-immutable.production.min.js | 2 +- src/seamless-immutable.js | 9 +++++---- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/seamless-immutable.development.js b/seamless-immutable.development.js index 484e72c..8b1213a 100644 --- a/seamless-immutable.development.js +++ b/seamless-immutable.development.js @@ -471,8 +471,16 @@ return makeImmutable(obj, mutatingObjectMethods); } + var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element')) || 0xeac7; + + function isReactElement(obj) { + return obj.hasOwnProperty && + obj.hasOwnProperty('$$typeof') && + obj.$$typeof === REACT_ELEMENT_TYPE; + } + function Immutable(obj, options) { - if (isImmutable(obj)) { + if (isImmutable(obj) || isReactElement(obj)) { return obj; } else if (obj instanceof Array) { return makeImmutableArray(obj.slice()); diff --git a/seamless-immutable.development.min.js b/seamless-immutable.development.min.js index 77dbc46..538bb2a 100644 --- a/seamless-immutable.development.min.js +++ b/seamless-immutable.development.min.js @@ -1 +1 @@ -/* (c) 2016, Richard Feldman, github.com/rtfeldman/seamless-immutable/blob/master/LICENSE */!function(){"use strict";function a(a,b,c){Object.defineProperty(a,b,{enumerable:!1,configurable:!1,writable:!1,value:c})}function b(b,c){a(b,c,function(){throw new f("The "+c+" method cannot be invoked on an Immutable data structure.")})}function c(b){a(b,A,!0)}function d(a){return"object"==typeof a?null===a||Boolean(Object.getOwnPropertyDescriptor(a,A)):!0}function e(a){return!(null===a||"object"!=typeof a||a instanceof Array||a instanceof Date)}function f(a){var b=new Error(a);return b.__proto__=f,b}function g(a,d){c(a);for(var e in d)d.hasOwnProperty(e)&&b(a,d[e]);return Object.freeze(a),a}function h(b,c){var d=b[c];a(b,c,function(){return z(d.apply(b,arguments))})}function i(a,b){if(a in this&&this[a]===b)return this;var c=p.call(this);return c[a]=z(b),k(c)}function j(a,b){var c=a[0];if(1===a.length)return i.call(this,c,b);var d,e=a.slice(1),f=this[c];if(d="object"==typeof f&&null!==f&&"function"==typeof f.setIn?f.setIn(e,b):j.call(G,e,b),c in this&&f===d)return this;var g=p.call(this);return g[c]=d,k(g)}function k(b){for(var c in E)if(E.hasOwnProperty(c)){var d=E[c];h(b,d)}a(b,"flatMap",n),a(b,"asObject",q),a(b,"asMutable",p),a(b,"set",i),a(b,"setIn",j);for(var e=0,f=b.length;f>e;e++)b[e]=z(b[e]);return g(b,D)}function l(b){return a(b,"asMutable",m),g(b,F)}function m(){return new Date(this.getTime())}function n(a){if(0===arguments.length)return this;var b,c=[],d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this);e instanceof Array?c.push.apply(c,e):c.push(e)}return k(c)}function o(a){if("undefined"==typeof a&&0===arguments.length)return this;if("function"!=typeof a){var b=a instanceof Array?a:Array.prototype.slice.call(arguments);a=function(a,c){return-1!==b.indexOf(c)}}var c=this.instantiateEmptyObject();for(var d in this)this.hasOwnProperty(d)&&a(this[d],d)===!1&&(c[d]=this[d]);return y(c,{instantiateEmptyObject:this.instantiateEmptyObject})}function p(a){var b,c,d=[];if(a&&a.deep)for(b=0,c=this.length;c>b;b++)d.push(r(this[b]));else for(b=0,c=this.length;c>b;b++)d.push(this[b]);return d}function q(a){"function"!=typeof a&&(a=function(a){return a});var b,c={},d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this),f=e[0],g=e[1];c[f]=g}return y(c)}function r(a){return!a||"object"!=typeof a||!Object.getOwnPropertyDescriptor(a,A)||a instanceof Date?a:a.asMutable({deep:!0})}function s(a,b){for(var c in a)Object.getOwnPropertyDescriptor(a,c)&&(b[c]=a[c]);return b}function t(a,b){function c(a,c,f){var g=z(c[f]),j=i&&i(a[f],g,b),k=a[f];if(void 0!==d||void 0!==j||!a.hasOwnProperty(f)||g!==k&&g===g){var l;l=j?j:h&&e(k)&&e(g)?k.merge(g,b):g,(k!==l&&l===l||!a.hasOwnProperty(f))&&(void 0===d&&(d=s(a,a.instantiateEmptyObject())),d[f]=l)}}if(0===arguments.length)return this;if(null===a||"object"!=typeof a)throw new TypeError("Immutable#merge can only be invoked with objects or arrays, not "+JSON.stringify(a));var d,f,g=a instanceof Array,h=b&&b.deep,i=b&&b.merger;if(g)for(var j=0;je;e++)b[e]=A(b[e]);return g(b,E)}function l(b){return a(b,"asMutable",m),g(b,G)}function m(){return new Date(this.getTime())}function n(a){if(0===arguments.length)return this;var b,c=[],d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this);e instanceof Array?c.push.apply(c,e):c.push(e)}return k(c)}function o(a){if("undefined"==typeof a&&0===arguments.length)return this;if("function"!=typeof a){var b=a instanceof Array?a:Array.prototype.slice.call(arguments);a=function(a,c){return-1!==b.indexOf(c)}}var c=this.instantiateEmptyObject();for(var d in this)this.hasOwnProperty(d)&&a(this[d],d)===!1&&(c[d]=this[d]);return y(c,{instantiateEmptyObject:this.instantiateEmptyObject})}function p(a){var b,c,d=[];if(a&&a.deep)for(b=0,c=this.length;c>b;b++)d.push(r(this[b]));else for(b=0,c=this.length;c>b;b++)d.push(this[b]);return d}function q(a){"function"!=typeof a&&(a=function(a){return a});var b,c={},d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this),f=e[0],g=e[1];c[f]=g}return y(c)}function r(a){return!a||"object"!=typeof a||!Object.getOwnPropertyDescriptor(a,B)||a instanceof Date?a:a.asMutable({deep:!0})}function s(a,b){for(var c in a)Object.getOwnPropertyDescriptor(a,c)&&(b[c]=a[c]);return b}function t(a,b){function c(a,c,f){var g=A(c[f]),j=i&&i(a[f],g,b),k=a[f];if(void 0!==d||void 0!==j||!a.hasOwnProperty(f)||g!==k&&g===g){var l;l=j?j:h&&e(k)&&e(g)?k.merge(g,b):g,(k!==l&&l===l||!a.hasOwnProperty(f))&&(void 0===d&&(d=s(a,a.instantiateEmptyObject())),d[f]=l)}}if(0===arguments.length)return this;if(null===a||"object"!=typeof a)throw new TypeError("Immutable#merge can only be invoked with objects or arrays, not "+JSON.stringify(a));var d,f,g=a instanceof Array,h=b&&b.deep,i=b&&b.merger;if(g)for(var j=0;je;e++)b[e]=y(b[e]);return f(b,C)}function k(b){return a(b,"asMutable",l),f(b,E)}function l(){return new Date(this.getTime())}function m(a){if(0===arguments.length)return this;var b,c=[],d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this);e instanceof Array?c.push.apply(c,e):c.push(e)}return j(c)}function n(a){if("undefined"==typeof a&&0===arguments.length)return this;if("function"!=typeof a){var b=a instanceof Array?a:Array.prototype.slice.call(arguments);a=function(a,c){return-1!==b.indexOf(c)}}var c=this.instantiateEmptyObject();for(var d in this)this.hasOwnProperty(d)&&a(this[d],d)===!1&&(c[d]=this[d]);return x(c,{instantiateEmptyObject:this.instantiateEmptyObject})}function o(a){var b,c,d=[];if(a&&a.deep)for(b=0,c=this.length;c>b;b++)d.push(q(this[b]));else for(b=0,c=this.length;c>b;b++)d.push(this[b]);return d}function p(a){"function"!=typeof a&&(a=function(a){return a});var b,c={},d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this),f=e[0],g=e[1];c[f]=g}return x(c)}function q(a){return!a||"object"!=typeof a||!Object.getOwnPropertyDescriptor(a,z)||a instanceof Date?a:a.asMutable({deep:!0})}function r(a,b){for(var c in a)Object.getOwnPropertyDescriptor(a,c)&&(b[c]=a[c]);return b}function s(a,b){function c(a,c,f){var g=y(c[f]),j=i&&i(a[f],g,b),k=a[f];if(void 0!==e||void 0!==j||!a.hasOwnProperty(f)||g!==k&&g===g){var l;l=j?j:h&&d(k)&&d(g)?k.merge(g,b):g,(k!==l&&l===l||!a.hasOwnProperty(f))&&(void 0===e&&(e=r(a,a.instantiateEmptyObject())),e[f]=l)}}if(0===arguments.length)return this;if(null===a||"object"!=typeof a)throw new TypeError("Immutable#merge can only be invoked with objects or arrays, not "+JSON.stringify(a));var e,f,g=a instanceof Array,h=b&&b.deep,i=b&&b.merger;if(g)for(var j=0;je;e++)b[e]=z(b[e]);return f(b,D)}function k(b){return a(b,"asMutable",l),f(b,F)}function l(){return new Date(this.getTime())}function m(a){if(0===arguments.length)return this;var b,c=[],d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this);e instanceof Array?c.push.apply(c,e):c.push(e)}return j(c)}function n(a){if("undefined"==typeof a&&0===arguments.length)return this;if("function"!=typeof a){var b=a instanceof Array?a:Array.prototype.slice.call(arguments);a=function(a,c){return-1!==b.indexOf(c)}}var c=this.instantiateEmptyObject();for(var d in this)this.hasOwnProperty(d)&&a(this[d],d)===!1&&(c[d]=this[d]);return x(c,{instantiateEmptyObject:this.instantiateEmptyObject})}function o(a){var b,c,d=[];if(a&&a.deep)for(b=0,c=this.length;c>b;b++)d.push(q(this[b]));else for(b=0,c=this.length;c>b;b++)d.push(this[b]);return d}function p(a){"function"!=typeof a&&(a=function(a){return a});var b,c={},d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this),f=e[0],g=e[1];c[f]=g}return x(c)}function q(a){return!a||"object"!=typeof a||!Object.getOwnPropertyDescriptor(a,A)||a instanceof Date?a:a.asMutable({deep:!0})}function r(a,b){for(var c in a)Object.getOwnPropertyDescriptor(a,c)&&(b[c]=a[c]);return b}function s(a,b){function c(a,c,f){var g=z(c[f]),j=i&&i(a[f],g,b),k=a[f];if(void 0!==e||void 0!==j||!a.hasOwnProperty(f)||g!==k&&g===g){var l;l=j?j:h&&d(k)&&d(g)?k.merge(g,b):g,(k!==l&&l===l||!a.hasOwnProperty(f))&&(void 0===e&&(e=r(a,a.instantiateEmptyObject())),e[f]=l)}}if(0===arguments.length)return this;if(null===a||"object"!=typeof a)throw new TypeError("Immutable#merge can only be invoked with objects or arrays, not "+JSON.stringify(a));var e,f,g=a instanceof Array,h=b&&b.deep,i=b&&b.merger;if(g)for(var j=0;j Date: Wed, 13 Apr 2016 11:29:36 +0000 Subject: [PATCH 4/7] Test is failing on IE11 --- seamless-immutable.development.js | 5 +++-- seamless-immutable.development.min.js | 2 +- seamless-immutable.production.min.js | 2 +- src/seamless-immutable.js | 5 +++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/seamless-immutable.development.js b/seamless-immutable.development.js index 8b1213a..2484fb2 100644 --- a/seamless-immutable.development.js +++ b/seamless-immutable.development.js @@ -471,12 +471,13 @@ return makeImmutable(obj, mutatingObjectMethods); } - var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element')) || 0xeac7; + var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element') + var REACT_ELEMENT_TYPE_FALLBACK = 0xeac7; function isReactElement(obj) { return obj.hasOwnProperty && obj.hasOwnProperty('$$typeof') && - obj.$$typeof === REACT_ELEMENT_TYPE; + obj.$$typeof === REACT_ELEMENT_TYPE_FALLBACK || obj.$$typeof === REACT_ELEMENT_TYPE; } function Immutable(obj, options) { diff --git a/seamless-immutable.development.min.js b/seamless-immutable.development.min.js index 538bb2a..c7799d7 100644 --- a/seamless-immutable.development.min.js +++ b/seamless-immutable.development.min.js @@ -1 +1 @@ -/* (c) 2016, Richard Feldman, github.com/rtfeldman/seamless-immutable/blob/master/LICENSE */!function(){"use strict";function a(a,b,c){Object.defineProperty(a,b,{enumerable:!1,configurable:!1,writable:!1,value:c})}function b(b,c){a(b,c,function(){throw new f("The "+c+" method cannot be invoked on an Immutable data structure.")})}function c(b){a(b,B,!0)}function d(a){return"object"==typeof a?null===a||Boolean(Object.getOwnPropertyDescriptor(a,B)):!0}function e(a){return!(null===a||"object"!=typeof a||a instanceof Array||a instanceof Date)}function f(a){var b=new Error(a);return b.__proto__=f,b}function g(a,d){c(a);for(var e in d)d.hasOwnProperty(e)&&b(a,d[e]);return Object.freeze(a),a}function h(b,c){var d=b[c];a(b,c,function(){return A(d.apply(b,arguments))})}function i(a,b){if(a in this&&this[a]===b)return this;var c=p.call(this);return c[a]=A(b),k(c)}function j(a,b){var c=a[0];if(1===a.length)return i.call(this,c,b);var d,e=a.slice(1),f=this[c];if(d="object"==typeof f&&null!==f&&"function"==typeof f.setIn?f.setIn(e,b):j.call(H,e,b),c in this&&f===d)return this;var g=p.call(this);return g[c]=d,k(g)}function k(b){for(var c in F)if(F.hasOwnProperty(c)){var d=F[c];h(b,d)}a(b,"flatMap",n),a(b,"asObject",q),a(b,"asMutable",p),a(b,"set",i),a(b,"setIn",j);for(var e=0,f=b.length;f>e;e++)b[e]=A(b[e]);return g(b,E)}function l(b){return a(b,"asMutable",m),g(b,G)}function m(){return new Date(this.getTime())}function n(a){if(0===arguments.length)return this;var b,c=[],d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this);e instanceof Array?c.push.apply(c,e):c.push(e)}return k(c)}function o(a){if("undefined"==typeof a&&0===arguments.length)return this;if("function"!=typeof a){var b=a instanceof Array?a:Array.prototype.slice.call(arguments);a=function(a,c){return-1!==b.indexOf(c)}}var c=this.instantiateEmptyObject();for(var d in this)this.hasOwnProperty(d)&&a(this[d],d)===!1&&(c[d]=this[d]);return y(c,{instantiateEmptyObject:this.instantiateEmptyObject})}function p(a){var b,c,d=[];if(a&&a.deep)for(b=0,c=this.length;c>b;b++)d.push(r(this[b]));else for(b=0,c=this.length;c>b;b++)d.push(this[b]);return d}function q(a){"function"!=typeof a&&(a=function(a){return a});var b,c={},d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this),f=e[0],g=e[1];c[f]=g}return y(c)}function r(a){return!a||"object"!=typeof a||!Object.getOwnPropertyDescriptor(a,B)||a instanceof Date?a:a.asMutable({deep:!0})}function s(a,b){for(var c in a)Object.getOwnPropertyDescriptor(a,c)&&(b[c]=a[c]);return b}function t(a,b){function c(a,c,f){var g=A(c[f]),j=i&&i(a[f],g,b),k=a[f];if(void 0!==d||void 0!==j||!a.hasOwnProperty(f)||g!==k&&g===g){var l;l=j?j:h&&e(k)&&e(g)?k.merge(g,b):g,(k!==l&&l===l||!a.hasOwnProperty(f))&&(void 0===d&&(d=s(a,a.instantiateEmptyObject())),d[f]=l)}}if(0===arguments.length)return this;if(null===a||"object"!=typeof a)throw new TypeError("Immutable#merge can only be invoked with objects or arrays, not "+JSON.stringify(a));var d,f,g=a instanceof Array,h=b&&b.deep,i=b&&b.merger;if(g)for(var j=0;je;e++)b[e]=A(b[e]);return g(b,E)}function l(b){return a(b,"asMutable",m),g(b,G)}function m(){return new Date(this.getTime())}function n(a){if(0===arguments.length)return this;var b,c=[],d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this);e instanceof Array?c.push.apply(c,e):c.push(e)}return k(c)}function o(a){if("undefined"==typeof a&&0===arguments.length)return this;if("function"!=typeof a){var b=a instanceof Array?a:Array.prototype.slice.call(arguments);a=function(a,c){return-1!==b.indexOf(c)}}var c=this.instantiateEmptyObject();for(var d in this)this.hasOwnProperty(d)&&a(this[d],d)===!1&&(c[d]=this[d]);return y(c,{instantiateEmptyObject:this.instantiateEmptyObject})}function p(a){var b,c,d=[];if(a&&a.deep)for(b=0,c=this.length;c>b;b++)d.push(r(this[b]));else for(b=0,c=this.length;c>b;b++)d.push(this[b]);return d}function q(a){"function"!=typeof a&&(a=function(a){return a});var b,c={},d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this),f=e[0],g=e[1];c[f]=g}return y(c)}function r(a){return!a||"object"!=typeof a||!Object.getOwnPropertyDescriptor(a,B)||a instanceof Date?a:a.asMutable({deep:!0})}function s(a,b){for(var c in a)Object.getOwnPropertyDescriptor(a,c)&&(b[c]=a[c]);return b}function t(a,b){function c(a,c,f){var g=A(c[f]),j=i&&i(a[f],g,b),k=a[f];if(void 0!==d||void 0!==j||!a.hasOwnProperty(f)||g!==k&&g===g){var l;l=j?j:h&&e(k)&&e(g)?k.merge(g,b):g,(k!==l&&l===l||!a.hasOwnProperty(f))&&(void 0===d&&(d=s(a,a.instantiateEmptyObject())),d[f]=l)}}if(0===arguments.length)return this;if(null===a||"object"!=typeof a)throw new TypeError("Immutable#merge can only be invoked with objects or arrays, not "+JSON.stringify(a));var d,f,g=a instanceof Array,h=b&&b.deep,i=b&&b.merger;if(g)for(var j=0;je;e++)b[e]=z(b[e]);return f(b,D)}function k(b){return a(b,"asMutable",l),f(b,F)}function l(){return new Date(this.getTime())}function m(a){if(0===arguments.length)return this;var b,c=[],d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this);e instanceof Array?c.push.apply(c,e):c.push(e)}return j(c)}function n(a){if("undefined"==typeof a&&0===arguments.length)return this;if("function"!=typeof a){var b=a instanceof Array?a:Array.prototype.slice.call(arguments);a=function(a,c){return-1!==b.indexOf(c)}}var c=this.instantiateEmptyObject();for(var d in this)this.hasOwnProperty(d)&&a(this[d],d)===!1&&(c[d]=this[d]);return x(c,{instantiateEmptyObject:this.instantiateEmptyObject})}function o(a){var b,c,d=[];if(a&&a.deep)for(b=0,c=this.length;c>b;b++)d.push(q(this[b]));else for(b=0,c=this.length;c>b;b++)d.push(this[b]);return d}function p(a){"function"!=typeof a&&(a=function(a){return a});var b,c={},d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this),f=e[0],g=e[1];c[f]=g}return x(c)}function q(a){return!a||"object"!=typeof a||!Object.getOwnPropertyDescriptor(a,A)||a instanceof Date?a:a.asMutable({deep:!0})}function r(a,b){for(var c in a)Object.getOwnPropertyDescriptor(a,c)&&(b[c]=a[c]);return b}function s(a,b){function c(a,c,f){var g=z(c[f]),j=i&&i(a[f],g,b),k=a[f];if(void 0!==e||void 0!==j||!a.hasOwnProperty(f)||g!==k&&g===g){var l;l=j?j:h&&d(k)&&d(g)?k.merge(g,b):g,(k!==l&&l===l||!a.hasOwnProperty(f))&&(void 0===e&&(e=r(a,a.instantiateEmptyObject())),e[f]=l)}}if(0===arguments.length)return this;if(null===a||"object"!=typeof a)throw new TypeError("Immutable#merge can only be invoked with objects or arrays, not "+JSON.stringify(a));var e,f,g=a instanceof Array,h=b&&b.deep,i=b&&b.merger;if(g)for(var j=0;je;e++)b[e]=z(b[e]);return f(b,D)}function k(b){return a(b,"asMutable",l),f(b,F)}function l(){return new Date(this.getTime())}function m(a){if(0===arguments.length)return this;var b,c=[],d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this);e instanceof Array?c.push.apply(c,e):c.push(e)}return j(c)}function n(a){if("undefined"==typeof a&&0===arguments.length)return this;if("function"!=typeof a){var b=a instanceof Array?a:Array.prototype.slice.call(arguments);a=function(a,c){return-1!==b.indexOf(c)}}var c=this.instantiateEmptyObject();for(var d in this)this.hasOwnProperty(d)&&a(this[d],d)===!1&&(c[d]=this[d]);return x(c,{instantiateEmptyObject:this.instantiateEmptyObject})}function o(a){var b,c,d=[];if(a&&a.deep)for(b=0,c=this.length;c>b;b++)d.push(q(this[b]));else for(b=0,c=this.length;c>b;b++)d.push(this[b]);return d}function p(a){"function"!=typeof a&&(a=function(a){return a});var b,c={},d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this),f=e[0],g=e[1];c[f]=g}return x(c)}function q(a){return!a||"object"!=typeof a||!Object.getOwnPropertyDescriptor(a,A)||a instanceof Date?a:a.asMutable({deep:!0})}function r(a,b){for(var c in a)Object.getOwnPropertyDescriptor(a,c)&&(b[c]=a[c]);return b}function s(a,b){function c(a,c,f){var g=z(c[f]),j=i&&i(a[f],g,b),k=a[f];if(void 0!==e||void 0!==j||!a.hasOwnProperty(f)||g!==k&&g===g){var l;l=j?j:h&&d(k)&&d(g)?k.merge(g,b):g,(k!==l&&l===l||!a.hasOwnProperty(f))&&(void 0===e&&(e=r(a,a.instantiateEmptyObject())),e[f]=l)}}if(0===arguments.length)return this;if(null===a||"object"!=typeof a)throw new TypeError("Immutable#merge can only be invoked with objects or arrays, not "+JSON.stringify(a));var e,f,g=a instanceof Array,h=b&&b.deep,i=b&&b.merger;if(g)for(var j=0;j Date: Wed, 13 Apr 2016 14:33:28 +0000 Subject: [PATCH 5/7] Add missing semicolon --- seamless-immutable.development.js | 2 +- src/seamless-immutable.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/seamless-immutable.development.js b/seamless-immutable.development.js index 2484fb2..8e50d92 100644 --- a/seamless-immutable.development.js +++ b/seamless-immutable.development.js @@ -471,7 +471,7 @@ return makeImmutable(obj, mutatingObjectMethods); } - var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element') + var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element'); var REACT_ELEMENT_TYPE_FALLBACK = 0xeac7; function isReactElement(obj) { diff --git a/src/seamless-immutable.js b/src/seamless-immutable.js index 650d5a8..3a74933 100644 --- a/src/seamless-immutable.js +++ b/src/seamless-immutable.js @@ -471,7 +471,7 @@ return makeImmutable(obj, mutatingObjectMethods); } - var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element') + var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element'); var REACT_ELEMENT_TYPE_FALLBACK = 0xeac7; function isReactElement(obj) { From 574f2ecf3963c08b7800c2e6a71de3070b0cad9a Mon Sep 17 00:00:00 2001 From: David Blurton Date: Tue, 19 Apr 2016 21:24:07 +0000 Subject: [PATCH 6/7] Add tests for react elements --- package.json | 1 + seamless-immutable.development.js | 20 ++++++++++++------- seamless-immutable.development.min.js | 2 +- seamless-immutable.production.min.js | 2 +- src/seamless-immutable.js | 26 +++++++++++++++---------- test/Immutable.spec.js | 28 +++++++++++++++++++++++++++ 6 files changed, 60 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 339798e..b397014 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "mocha": "2.4.5", "mocha-istanbul": "0.2.0", "mocha-lcov-reporter": "1.2.0", + "react": "^15.0.1", "zuul": "3.9.0" }, "scripts": { diff --git a/seamless-immutable.development.js b/seamless-immutable.development.js index 8e50d92..dd9302c 100644 --- a/seamless-immutable.development.js +++ b/seamless-immutable.development.js @@ -1,6 +1,9 @@ (function() { "use strict"; + // https://github.com/facebook/react/blob/v15.0.1/src/isomorphic/classic/element/ReactElement.js#L21 + var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element')) || 0xeac7; + function addPropertyTo(target, methodName, value) { Object.defineProperty(target, methodName, { enumerable: false, @@ -457,6 +460,10 @@ // Finalizes an object with immutable methods, freezes it, and returns it. function makeImmutableObject(obj, options) { + if (isReactElement(obj)) { + return obj + } + var instantiateEmptyObject = (options && options.instantiateEmptyObject) ? options.instantiateEmptyObject : instantiatePlainObject; @@ -471,17 +478,16 @@ return makeImmutable(obj, mutatingObjectMethods); } - var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element'); - var REACT_ELEMENT_TYPE_FALLBACK = 0xeac7; - + // Returns true if object is a valid react element + // https://github.com/facebook/react/blob/v15.0.1/src/isomorphic/classic/element/ReactElement.js#L326 function isReactElement(obj) { - return obj.hasOwnProperty && - obj.hasOwnProperty('$$typeof') && - obj.$$typeof === REACT_ELEMENT_TYPE_FALLBACK || obj.$$typeof === REACT_ELEMENT_TYPE; + return typeof obj === 'object' && + obj !== null && + obj.$$typeof === REACT_ELEMENT_TYPE; } function Immutable(obj, options) { - if (isImmutable(obj) || isReactElement(obj)) { + if (isImmutable(obj)) { return obj; } else if (obj instanceof Array) { return makeImmutableArray(obj.slice()); diff --git a/seamless-immutable.development.min.js b/seamless-immutable.development.min.js index c7799d7..2f4614f 100644 --- a/seamless-immutable.development.min.js +++ b/seamless-immutable.development.min.js @@ -1 +1 @@ -/* (c) 2016, Richard Feldman, github.com/rtfeldman/seamless-immutable/blob/master/LICENSE */!function(){"use strict";function a(a,b,c){Object.defineProperty(a,b,{enumerable:!1,configurable:!1,writable:!1,value:c})}function b(b,c){a(b,c,function(){throw new f("The "+c+" method cannot be invoked on an Immutable data structure.")})}function c(b){a(b,B,!0)}function d(a){return"object"==typeof a?null===a||Boolean(Object.getOwnPropertyDescriptor(a,B)):!0}function e(a){return!(null===a||"object"!=typeof a||a instanceof Array||a instanceof Date)}function f(a){var b=new Error(a);return b.__proto__=f,b}function g(a,d){c(a);for(var e in d)d.hasOwnProperty(e)&&b(a,d[e]);return Object.freeze(a),a}function h(b,c){var d=b[c];a(b,c,function(){return A(d.apply(b,arguments))})}function i(a,b){if(a in this&&this[a]===b)return this;var c=p.call(this);return c[a]=A(b),k(c)}function j(a,b){var c=a[0];if(1===a.length)return i.call(this,c,b);var d,e=a.slice(1),f=this[c];if(d="object"==typeof f&&null!==f&&"function"==typeof f.setIn?f.setIn(e,b):j.call(H,e,b),c in this&&f===d)return this;var g=p.call(this);return g[c]=d,k(g)}function k(b){for(var c in F)if(F.hasOwnProperty(c)){var d=F[c];h(b,d)}a(b,"flatMap",n),a(b,"asObject",q),a(b,"asMutable",p),a(b,"set",i),a(b,"setIn",j);for(var e=0,f=b.length;f>e;e++)b[e]=A(b[e]);return g(b,E)}function l(b){return a(b,"asMutable",m),g(b,G)}function m(){return new Date(this.getTime())}function n(a){if(0===arguments.length)return this;var b,c=[],d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this);e instanceof Array?c.push.apply(c,e):c.push(e)}return k(c)}function o(a){if("undefined"==typeof a&&0===arguments.length)return this;if("function"!=typeof a){var b=a instanceof Array?a:Array.prototype.slice.call(arguments);a=function(a,c){return-1!==b.indexOf(c)}}var c=this.instantiateEmptyObject();for(var d in this)this.hasOwnProperty(d)&&a(this[d],d)===!1&&(c[d]=this[d]);return y(c,{instantiateEmptyObject:this.instantiateEmptyObject})}function p(a){var b,c,d=[];if(a&&a.deep)for(b=0,c=this.length;c>b;b++)d.push(r(this[b]));else for(b=0,c=this.length;c>b;b++)d.push(this[b]);return d}function q(a){"function"!=typeof a&&(a=function(a){return a});var b,c={},d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this),f=e[0],g=e[1];c[f]=g}return y(c)}function r(a){return!a||"object"!=typeof a||!Object.getOwnPropertyDescriptor(a,B)||a instanceof Date?a:a.asMutable({deep:!0})}function s(a,b){for(var c in a)Object.getOwnPropertyDescriptor(a,c)&&(b[c]=a[c]);return b}function t(a,b){function c(a,c,f){var g=A(c[f]),j=i&&i(a[f],g,b),k=a[f];if(void 0!==d||void 0!==j||!a.hasOwnProperty(f)||g!==k&&g===g){var l;l=j?j:h&&e(k)&&e(g)?k.merge(g,b):g,(k!==l&&l===l||!a.hasOwnProperty(f))&&(void 0===d&&(d=s(a,a.instantiateEmptyObject())),d[f]=l)}}if(0===arguments.length)return this;if(null===a||"object"!=typeof a)throw new TypeError("Immutable#merge can only be invoked with objects or arrays, not "+JSON.stringify(a));var d,f,g=a instanceof Array,h=b&&b.deep,i=b&&b.merger;if(g)for(var j=0;je;e++)b[e]=A(b[e]);return g(b,F)}function l(b){return a(b,"asMutable",m),g(b,H)}function m(){return new Date(this.getTime())}function n(a){if(0===arguments.length)return this;var b,c=[],d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this);e instanceof Array?c.push.apply(c,e):c.push(e)}return k(c)}function o(a){if("undefined"==typeof a&&0===arguments.length)return this;if("function"!=typeof a){var b=a instanceof Array?a:Array.prototype.slice.call(arguments);a=function(a,c){return-1!==b.indexOf(c)}}var c=this.instantiateEmptyObject();for(var d in this)this.hasOwnProperty(d)&&a(this[d],d)===!1&&(c[d]=this[d]);return y(c,{instantiateEmptyObject:this.instantiateEmptyObject})}function p(a){var b,c,d=[];if(a&&a.deep)for(b=0,c=this.length;c>b;b++)d.push(r(this[b]));else for(b=0,c=this.length;c>b;b++)d.push(this[b]);return d}function q(a){"function"!=typeof a&&(a=function(a){return a});var b,c={},d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this),f=e[0],g=e[1];c[f]=g}return y(c)}function r(a){return!a||"object"!=typeof a||!Object.getOwnPropertyDescriptor(a,C)||a instanceof Date?a:a.asMutable({deep:!0})}function s(a,b){for(var c in a)Object.getOwnPropertyDescriptor(a,c)&&(b[c]=a[c]);return b}function t(a,b){function c(a,c,f){var g=A(c[f]),j=i&&i(a[f],g,b),k=a[f];if(void 0!==d||void 0!==j||!a.hasOwnProperty(f)||g!==k&&g===g){var l;l=j?j:h&&e(k)&&e(g)?k.merge(g,b):g,(k!==l&&l===l||!a.hasOwnProperty(f))&&(void 0===d&&(d=s(a,a.instantiateEmptyObject())),d[f]=l)}}if(0===arguments.length)return this;if(null===a||"object"!=typeof a)throw new TypeError("Immutable#merge can only be invoked with objects or arrays, not "+JSON.stringify(a));var d,f,g=a instanceof Array,h=b&&b.deep,i=b&&b.merger;if(g)for(var j=0;je;e++)b[e]=z(b[e]);return f(b,D)}function k(b){return a(b,"asMutable",l),f(b,F)}function l(){return new Date(this.getTime())}function m(a){if(0===arguments.length)return this;var b,c=[],d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this);e instanceof Array?c.push.apply(c,e):c.push(e)}return j(c)}function n(a){if("undefined"==typeof a&&0===arguments.length)return this;if("function"!=typeof a){var b=a instanceof Array?a:Array.prototype.slice.call(arguments);a=function(a,c){return-1!==b.indexOf(c)}}var c=this.instantiateEmptyObject();for(var d in this)this.hasOwnProperty(d)&&a(this[d],d)===!1&&(c[d]=this[d]);return x(c,{instantiateEmptyObject:this.instantiateEmptyObject})}function o(a){var b,c,d=[];if(a&&a.deep)for(b=0,c=this.length;c>b;b++)d.push(q(this[b]));else for(b=0,c=this.length;c>b;b++)d.push(this[b]);return d}function p(a){"function"!=typeof a&&(a=function(a){return a});var b,c={},d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this),f=e[0],g=e[1];c[f]=g}return x(c)}function q(a){return!a||"object"!=typeof a||!Object.getOwnPropertyDescriptor(a,A)||a instanceof Date?a:a.asMutable({deep:!0})}function r(a,b){for(var c in a)Object.getOwnPropertyDescriptor(a,c)&&(b[c]=a[c]);return b}function s(a,b){function c(a,c,f){var g=z(c[f]),j=i&&i(a[f],g,b),k=a[f];if(void 0!==e||void 0!==j||!a.hasOwnProperty(f)||g!==k&&g===g){var l;l=j?j:h&&d(k)&&d(g)?k.merge(g,b):g,(k!==l&&l===l||!a.hasOwnProperty(f))&&(void 0===e&&(e=r(a,a.instantiateEmptyObject())),e[f]=l)}}if(0===arguments.length)return this;if(null===a||"object"!=typeof a)throw new TypeError("Immutable#merge can only be invoked with objects or arrays, not "+JSON.stringify(a));var e,f,g=a instanceof Array,h=b&&b.deep,i=b&&b.merger;if(g)for(var j=0;je;e++)b[e]=z(b[e]);return f(b,E)}function k(b){return a(b,"asMutable",l),f(b,G)}function l(){return new Date(this.getTime())}function m(a){if(0===arguments.length)return this;var b,c=[],d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this);e instanceof Array?c.push.apply(c,e):c.push(e)}return j(c)}function n(a){if("undefined"==typeof a&&0===arguments.length)return this;if("function"!=typeof a){var b=a instanceof Array?a:Array.prototype.slice.call(arguments);a=function(a,c){return-1!==b.indexOf(c)}}var c=this.instantiateEmptyObject();for(var d in this)this.hasOwnProperty(d)&&a(this[d],d)===!1&&(c[d]=this[d]);return x(c,{instantiateEmptyObject:this.instantiateEmptyObject})}function o(a){var b,c,d=[];if(a&&a.deep)for(b=0,c=this.length;c>b;b++)d.push(q(this[b]));else for(b=0,c=this.length;c>b;b++)d.push(this[b]);return d}function p(a){"function"!=typeof a&&(a=function(a){return a});var b,c={},d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this),f=e[0],g=e[1];c[f]=g}return x(c)}function q(a){return!a||"object"!=typeof a||!Object.getOwnPropertyDescriptor(a,B)||a instanceof Date?a:a.asMutable({deep:!0})}function r(a,b){for(var c in a)Object.getOwnPropertyDescriptor(a,c)&&(b[c]=a[c]);return b}function s(a,b){function c(a,c,f){var g=z(c[f]),j=i&&i(a[f],g,b),k=a[f];if(void 0!==e||void 0!==j||!a.hasOwnProperty(f)||g!==k&&g===g){var l;l=j?j:h&&d(k)&&d(g)?k.merge(g,b):g,(k!==l&&l===l||!a.hasOwnProperty(f))&&(void 0===e&&(e=r(a,a.instantiateEmptyObject())),e[f]=l)}}if(0===arguments.length)return this;if(null===a||"object"!=typeof a)throw new TypeError("Immutable#merge can only be invoked with objects or arrays, not "+JSON.stringify(a));var e,f,g=a instanceof Array,h=b&&b.deep,i=b&&b.merger;if(g)for(var j=0;j Date: Tue, 19 Apr 2016 21:53:24 +0000 Subject: [PATCH 7/7] React freeze elements so don't test for this --- seamless-immutable.development.js | 11 ++++------- seamless-immutable.development.min.js | 2 +- seamless-immutable.production.min.js | 2 +- src/seamless-immutable.js | 25 +++++++++++-------------- test/Immutable.spec.js | 2 -- 5 files changed, 17 insertions(+), 25 deletions(-) diff --git a/seamless-immutable.development.js b/seamless-immutable.development.js index dd9302c..ce13abf 100644 --- a/seamless-immutable.development.js +++ b/seamless-immutable.development.js @@ -2,7 +2,8 @@ "use strict"; // https://github.com/facebook/react/blob/v15.0.1/src/isomorphic/classic/element/ReactElement.js#L21 - var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element')) || 0xeac7; + var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element'); + var REACT_ELEMENT_TYPE_FALLBACK = 0xeac7; function addPropertyTo(target, methodName, value) { Object.defineProperty(target, methodName, { @@ -460,10 +461,6 @@ // Finalizes an object with immutable methods, freezes it, and returns it. function makeImmutableObject(obj, options) { - if (isReactElement(obj)) { - return obj - } - var instantiateEmptyObject = (options && options.instantiateEmptyObject) ? options.instantiateEmptyObject : instantiatePlainObject; @@ -483,11 +480,11 @@ function isReactElement(obj) { return typeof obj === 'object' && obj !== null && - obj.$$typeof === REACT_ELEMENT_TYPE; + (obj.$$typeof === REACT_ELEMENT_TYPE_FALLBACK || obj.$$typeof === REACT_ELEMENT_TYPE); } function Immutable(obj, options) { - if (isImmutable(obj)) { + if (isImmutable(obj) || isReactElement(obj)) { return obj; } else if (obj instanceof Array) { return makeImmutableArray(obj.slice()); diff --git a/seamless-immutable.development.min.js b/seamless-immutable.development.min.js index 2f4614f..c7a8672 100644 --- a/seamless-immutable.development.min.js +++ b/seamless-immutable.development.min.js @@ -1 +1 @@ -/* (c) 2016, Richard Feldman, github.com/rtfeldman/seamless-immutable/blob/master/LICENSE */!function(){"use strict";function a(a,b,c){Object.defineProperty(a,b,{enumerable:!1,configurable:!1,writable:!1,value:c})}function b(b,c){a(b,c,function(){throw new f("The "+c+" method cannot be invoked on an Immutable data structure.")})}function c(b){a(b,C,!0)}function d(a){return"object"==typeof a?null===a||Boolean(Object.getOwnPropertyDescriptor(a,C)):!0}function e(a){return!(null===a||"object"!=typeof a||a instanceof Array||a instanceof Date)}function f(a){var b=new Error(a);return b.__proto__=f,b}function g(a,d){c(a);for(var e in d)d.hasOwnProperty(e)&&b(a,d[e]);return Object.freeze(a),a}function h(b,c){var d=b[c];a(b,c,function(){return A(d.apply(b,arguments))})}function i(a,b){if(a in this&&this[a]===b)return this;var c=p.call(this);return c[a]=A(b),k(c)}function j(a,b){var c=a[0];if(1===a.length)return i.call(this,c,b);var d,e=a.slice(1),f=this[c];if(d="object"==typeof f&&null!==f&&"function"==typeof f.setIn?f.setIn(e,b):j.call(I,e,b),c in this&&f===d)return this;var g=p.call(this);return g[c]=d,k(g)}function k(b){for(var c in G)if(G.hasOwnProperty(c)){var d=G[c];h(b,d)}a(b,"flatMap",n),a(b,"asObject",q),a(b,"asMutable",p),a(b,"set",i),a(b,"setIn",j);for(var e=0,f=b.length;f>e;e++)b[e]=A(b[e]);return g(b,F)}function l(b){return a(b,"asMutable",m),g(b,H)}function m(){return new Date(this.getTime())}function n(a){if(0===arguments.length)return this;var b,c=[],d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this);e instanceof Array?c.push.apply(c,e):c.push(e)}return k(c)}function o(a){if("undefined"==typeof a&&0===arguments.length)return this;if("function"!=typeof a){var b=a instanceof Array?a:Array.prototype.slice.call(arguments);a=function(a,c){return-1!==b.indexOf(c)}}var c=this.instantiateEmptyObject();for(var d in this)this.hasOwnProperty(d)&&a(this[d],d)===!1&&(c[d]=this[d]);return y(c,{instantiateEmptyObject:this.instantiateEmptyObject})}function p(a){var b,c,d=[];if(a&&a.deep)for(b=0,c=this.length;c>b;b++)d.push(r(this[b]));else for(b=0,c=this.length;c>b;b++)d.push(this[b]);return d}function q(a){"function"!=typeof a&&(a=function(a){return a});var b,c={},d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this),f=e[0],g=e[1];c[f]=g}return y(c)}function r(a){return!a||"object"!=typeof a||!Object.getOwnPropertyDescriptor(a,C)||a instanceof Date?a:a.asMutable({deep:!0})}function s(a,b){for(var c in a)Object.getOwnPropertyDescriptor(a,c)&&(b[c]=a[c]);return b}function t(a,b){function c(a,c,f){var g=A(c[f]),j=i&&i(a[f],g,b),k=a[f];if(void 0!==d||void 0!==j||!a.hasOwnProperty(f)||g!==k&&g===g){var l;l=j?j:h&&e(k)&&e(g)?k.merge(g,b):g,(k!==l&&l===l||!a.hasOwnProperty(f))&&(void 0===d&&(d=s(a,a.instantiateEmptyObject())),d[f]=l)}}if(0===arguments.length)return this;if(null===a||"object"!=typeof a)throw new TypeError("Immutable#merge can only be invoked with objects or arrays, not "+JSON.stringify(a));var d,f,g=a instanceof Array,h=b&&b.deep,i=b&&b.merger;if(g)for(var j=0;je;e++)b[e]=A(b[e]);return g(b,G)}function l(b){return a(b,"asMutable",m),g(b,I)}function m(){return new Date(this.getTime())}function n(a){if(0===arguments.length)return this;var b,c=[],d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this);e instanceof Array?c.push.apply(c,e):c.push(e)}return k(c)}function o(a){if("undefined"==typeof a&&0===arguments.length)return this;if("function"!=typeof a){var b=a instanceof Array?a:Array.prototype.slice.call(arguments);a=function(a,c){return-1!==b.indexOf(c)}}var c=this.instantiateEmptyObject();for(var d in this)this.hasOwnProperty(d)&&a(this[d],d)===!1&&(c[d]=this[d]);return y(c,{instantiateEmptyObject:this.instantiateEmptyObject})}function p(a){var b,c,d=[];if(a&&a.deep)for(b=0,c=this.length;c>b;b++)d.push(r(this[b]));else for(b=0,c=this.length;c>b;b++)d.push(this[b]);return d}function q(a){"function"!=typeof a&&(a=function(a){return a});var b,c={},d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this),f=e[0],g=e[1];c[f]=g}return y(c)}function r(a){return!a||"object"!=typeof a||!Object.getOwnPropertyDescriptor(a,D)||a instanceof Date?a:a.asMutable({deep:!0})}function s(a,b){for(var c in a)Object.getOwnPropertyDescriptor(a,c)&&(b[c]=a[c]);return b}function t(a,b){function c(a,c,f){var g=A(c[f]),j=i&&i(a[f],g,b),k=a[f];if(void 0!==d||void 0!==j||!a.hasOwnProperty(f)||g!==k&&g===g){var l;l=j?j:h&&e(k)&&e(g)?k.merge(g,b):g,(k!==l&&l===l||!a.hasOwnProperty(f))&&(void 0===d&&(d=s(a,a.instantiateEmptyObject())),d[f]=l)}}if(0===arguments.length)return this;if(null===a||"object"!=typeof a)throw new TypeError("Immutable#merge can only be invoked with objects or arrays, not "+JSON.stringify(a));var d,f,g=a instanceof Array,h=b&&b.deep,i=b&&b.merger;if(g)for(var j=0;je;e++)b[e]=z(b[e]);return f(b,E)}function k(b){return a(b,"asMutable",l),f(b,G)}function l(){return new Date(this.getTime())}function m(a){if(0===arguments.length)return this;var b,c=[],d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this);e instanceof Array?c.push.apply(c,e):c.push(e)}return j(c)}function n(a){if("undefined"==typeof a&&0===arguments.length)return this;if("function"!=typeof a){var b=a instanceof Array?a:Array.prototype.slice.call(arguments);a=function(a,c){return-1!==b.indexOf(c)}}var c=this.instantiateEmptyObject();for(var d in this)this.hasOwnProperty(d)&&a(this[d],d)===!1&&(c[d]=this[d]);return x(c,{instantiateEmptyObject:this.instantiateEmptyObject})}function o(a){var b,c,d=[];if(a&&a.deep)for(b=0,c=this.length;c>b;b++)d.push(q(this[b]));else for(b=0,c=this.length;c>b;b++)d.push(this[b]);return d}function p(a){"function"!=typeof a&&(a=function(a){return a});var b,c={},d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this),f=e[0],g=e[1];c[f]=g}return x(c)}function q(a){return!a||"object"!=typeof a||!Object.getOwnPropertyDescriptor(a,B)||a instanceof Date?a:a.asMutable({deep:!0})}function r(a,b){for(var c in a)Object.getOwnPropertyDescriptor(a,c)&&(b[c]=a[c]);return b}function s(a,b){function c(a,c,f){var g=z(c[f]),j=i&&i(a[f],g,b),k=a[f];if(void 0!==e||void 0!==j||!a.hasOwnProperty(f)||g!==k&&g===g){var l;l=j?j:h&&d(k)&&d(g)?k.merge(g,b):g,(k!==l&&l===l||!a.hasOwnProperty(f))&&(void 0===e&&(e=r(a,a.instantiateEmptyObject())),e[f]=l)}}if(0===arguments.length)return this;if(null===a||"object"!=typeof a)throw new TypeError("Immutable#merge can only be invoked with objects or arrays, not "+JSON.stringify(a));var e,f,g=a instanceof Array,h=b&&b.deep,i=b&&b.merger;if(g)for(var j=0;je;e++)b[e]=z(b[e]);return f(b,F)}function k(b){return a(b,"asMutable",l),f(b,H)}function l(){return new Date(this.getTime())}function m(a){if(0===arguments.length)return this;var b,c=[],d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this);e instanceof Array?c.push.apply(c,e):c.push(e)}return j(c)}function n(a){if("undefined"==typeof a&&0===arguments.length)return this;if("function"!=typeof a){var b=a instanceof Array?a:Array.prototype.slice.call(arguments);a=function(a,c){return-1!==b.indexOf(c)}}var c=this.instantiateEmptyObject();for(var d in this)this.hasOwnProperty(d)&&a(this[d],d)===!1&&(c[d]=this[d]);return x(c,{instantiateEmptyObject:this.instantiateEmptyObject})}function o(a){var b,c,d=[];if(a&&a.deep)for(b=0,c=this.length;c>b;b++)d.push(q(this[b]));else for(b=0,c=this.length;c>b;b++)d.push(this[b]);return d}function p(a){"function"!=typeof a&&(a=function(a){return a});var b,c={},d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this),f=e[0],g=e[1];c[f]=g}return x(c)}function q(a){return!a||"object"!=typeof a||!Object.getOwnPropertyDescriptor(a,C)||a instanceof Date?a:a.asMutable({deep:!0})}function r(a,b){for(var c in a)Object.getOwnPropertyDescriptor(a,c)&&(b[c]=a[c]);return b}function s(a,b){function c(a,c,f){var g=z(c[f]),j=i&&i(a[f],g,b),k=a[f];if(void 0!==e||void 0!==j||!a.hasOwnProperty(f)||g!==k&&g===g){var l;l=j?j:h&&d(k)&&d(g)?k.merge(g,b):g,(k!==l&&l===l||!a.hasOwnProperty(f))&&(void 0===e&&(e=r(a,a.instantiateEmptyObject())),e[f]=l)}}if(0===arguments.length)return this;if(null===a||"object"!=typeof a)throw new TypeError("Immutable#merge can only be invoked with objects or arrays, not "+JSON.stringify(a));var e,f,g=a instanceof Array,h=b&&b.deep,i=b&&b.merger;if(g)for(var j=0;j