Skip to content

Commit

Permalink
Check if passed type is not on Object.prototype, explain case
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzysztof Borowy committed Nov 21, 2017
1 parent 502d45c commit 65ab36c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/hot/client/hotPatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,18 @@ if (typeof global.__REACT_HOT_LOADER__ !== 'undefined') {
if (
typeof type !== 'function' ||
typeof uniqueLocalName !== 'string' ||
typeof fileName !== 'string'
typeof fileName !== 'string' ||
/**
* In case where someone extract function from a prototype
* example: `const hasOwnProperty = Object.keys.hasOwnProperty`,
* then hasOwnProperty is being patched by HMR
* Here: https://github.com/gaearon/react-hot-loader/blob/master/src/patch.dev.js#L14-L20
* When we get to point where we retrives keys from patched functions
* here: https://github.com/gaearon/react-hot-loader/blob/master/src/patch.dev.js#L43
* We'll be actually looping over `hasOwnPrototype`'s arities, which are `undefined`
* Accessing properties on `undefined` will throw an error
*/
Object.prototype[uniqueLocalName]
) {
return;
}
Expand Down

0 comments on commit 65ab36c

Please sign in to comment.