1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Copy all properties and descriptors when patching React (#1101)

* patch-react: copy non-enumerable properties and descriptors

* fix syntax error

* remove getOwnPropertyDescriptors polyfil
This commit is contained in:
Naoyuki Kanezawa 2017-02-15 12:00:39 +09:00 committed by Arunoda Susiripala
parent 2c85b367ce
commit 437fb2cbd3

View file

@ -105,11 +105,11 @@ function wrap (fn, around) {
return around.call(this, fn, ...args)
}
// copy all properties
Object.assign(_fn, fn)
_fn.displayName = fn.displayName || fn.name
_fn.prototype = fn.prototype
for (const [k, d] of Object.entries(Object.getOwnPropertyDescriptors(fn))) {
try {
Object.defineProperty(_fn, k, d)
} catch (e) {}
}
_fn.__wrapped = fn.__wrapped = _fn