hoist-non-react-statics
Advanced tools
Comparing version 2.0.0 to 2.1.0
26
index.js
@@ -23,2 +23,3 @@ /** | ||
var objectPrototype = getPrototypeOf && getPrototypeOf(Object); | ||
var getOwnPropertyNames = Object.getOwnPropertyNames; | ||
@@ -35,5 +36,13 @@ module.exports = function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) { | ||
for (var key in sourceComponent) { | ||
var keys = getOwnPropertyNames(sourceComponent); | ||
if (getOwnPropertySymbols) { | ||
keys = keys.concat(getOwnPropertySymbols(sourceComponent)); | ||
} | ||
for (var i = 0; i < keys.length; ++i) { | ||
var key = keys[i]; | ||
if (!REACT_STATICS[key] && (!blacklist || !blacklist[key])) { | ||
if (hasOwnProperty.call(sourceComponent, key)) { | ||
// Only hoist enumerables and non-enumerable functions | ||
if(propIsEnumerable.call(sourceComponent, key) || typeof sourceComponent[key] === 'function') { | ||
try { // Avoid failures from read-only properties | ||
@@ -46,15 +55,2 @@ targetComponent[key] = sourceComponent[key]; | ||
if (getOwnPropertySymbols) { | ||
var symbols = getOwnPropertySymbols(sourceComponent); | ||
for (var i = 0; i < symbols.length; i++) { | ||
if (!REACT_STATICS[symbols[i]] && (!blacklist || !blacklist[symbols[i]])) { | ||
if (propIsEnumerable.call(sourceComponent, symbols[i])) { | ||
try { // Avoid failures from read-only properties | ||
targetComponent[symbols[i]] = sourceComponent[symbols[i]]; | ||
} catch(e) {} | ||
} | ||
} | ||
} | ||
} | ||
return targetComponent; | ||
@@ -61,0 +57,0 @@ } |
@@ -0,0 +0,0 @@ Software License Agreement (BSD License) |
{ | ||
"name": "hoist-non-react-statics", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Copies non-react specific statics from a child component to a parent component", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -0,0 +0,0 @@ # hoist-non-react-statics |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7002
48