diff --git a/modules/makeAssimilatePrototype.js b/modules/makeAssimilatePrototype.js index edf6146..bfcf91f 100644 --- a/modules/makeAssimilatePrototype.js +++ b/modules/makeAssimilatePrototype.js @@ -17,10 +17,17 @@ module.exports = function makeAssimilatePrototype() { }; } + function copyProperty(source, target, name) { + var descriptor = Object.getOwnPropertyDescriptor(source, name); + Object.defineProperty(target, name, descriptor); + return descriptor; + } + function patchProperty(proto, key) { - proto[key] = storedPrototype[key]; + var descriptor = copyProperty(storedPrototype, proto, key); - if (typeof proto[key] !== 'function' || + if (!descriptor.value || + typeof proto[key] !== 'function' || key === 'type' || key === 'constructor') { return; @@ -41,7 +48,7 @@ module.exports = function makeAssimilatePrototype() { storedPrototype = {}; Object.getOwnPropertyNames(freshPrototype).forEach(function (key) { - storedPrototype[key] = freshPrototype[key]; + copyProperty(freshPrototype, storedPrototype, key); }); } @@ -63,4 +70,4 @@ module.exports = function makeAssimilatePrototype() { reconcileWithStoredPrototypes(freshPrototype); freshPrototype.__isAssimilatedByReactHotAPI = true; }; -}; \ No newline at end of file +};