rc-resize-observer
Advanced tools
| export declare function supportRef(node: any): boolean; |
+16
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| function supportRef(node) { | ||
| // Function component | ||
| if (node.type && node.type.prototype && !node.type.prototype.render) { | ||
| return false; | ||
| } | ||
| return true; | ||
| } | ||
| exports.supportRef = supportRef; |
| export declare function supportRef(node: any): boolean; |
+16
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| function supportRef(node) { | ||
| // Function component | ||
| if (node.type && node.type.prototype && !node.type.prototype.render) { | ||
| return false; | ||
| } | ||
| return true; | ||
| } | ||
| exports.supportRef = supportRef; |
+1
-0
@@ -31,2 +31,3 @@ import * as React from 'react'; | ||
| onResize: ResizeObserverCallback; | ||
| setChildNode: (node: RefNode) => void; | ||
| destroyObserver(): void; | ||
@@ -33,0 +34,0 @@ render(): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | React.ReactElement<unknown, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>[] | null; |
+11
-19
@@ -49,4 +49,8 @@ "use strict"; | ||
| var ref_1 = require("rc-util/lib/ref"); | ||
| var resize_observer_polyfill_1 = __importDefault(require("resize-observer-polyfill")); | ||
| var util_1 = require("./util"); | ||
| var INTERNAL_PREFIX_KEY = 'rc-observer-key'; // Still need to be compatible with React 15, we use class component here | ||
@@ -104,2 +108,6 @@ | ||
| _this.setChildNode = function (node) { | ||
| _this.childNode = node; | ||
| }; | ||
| return _this; | ||
@@ -158,4 +166,2 @@ } | ||
| value: function render() { | ||
| var _this2 = this; | ||
| var children = this.props.children; | ||
@@ -173,20 +179,6 @@ var childNodes = toArray_1.default(children); | ||
| if (React.isValidElement(childNode)) { | ||
| var _ref = childNode.ref; | ||
| if (React.isValidElement(childNode) && util_1.supportRef(childNode)) { | ||
| var ref = childNode.ref; | ||
| childNodes[0] = React.cloneElement(childNode, { | ||
| ref: function ref(node) { | ||
| _this2.childNode = node; // Should forward ref | ||
| if (!_ref) { | ||
| return; | ||
| } | ||
| var type = _typeof(_ref); | ||
| if (type === 'function') { | ||
| _ref(node); | ||
| } else if (type === 'object') { | ||
| _ref.current = node; | ||
| } | ||
| } | ||
| ref: ref_1.composeRef(ref, this.setChildNode) | ||
| }); | ||
@@ -193,0 +185,0 @@ } |
+1
-0
@@ -31,2 +31,3 @@ import * as React from 'react'; | ||
| onResize: ResizeObserverCallback; | ||
| setChildNode: (node: RefNode) => void; | ||
| destroyObserver(): void; | ||
@@ -33,0 +34,0 @@ render(): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | React.ReactElement<unknown, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>[] | null; |
+11
-19
@@ -49,4 +49,8 @@ "use strict"; | ||
| var ref_1 = require("rc-util/lib/ref"); | ||
| var resize_observer_polyfill_1 = __importDefault(require("resize-observer-polyfill")); | ||
| var util_1 = require("./util"); | ||
| var INTERNAL_PREFIX_KEY = 'rc-observer-key'; // Still need to be compatible with React 15, we use class component here | ||
@@ -104,2 +108,6 @@ | ||
| _this.setChildNode = function (node) { | ||
| _this.childNode = node; | ||
| }; | ||
| return _this; | ||
@@ -158,4 +166,2 @@ } | ||
| value: function render() { | ||
| var _this2 = this; | ||
| var children = this.props.children; | ||
@@ -173,20 +179,6 @@ var childNodes = toArray_1.default(children); | ||
| if (React.isValidElement(childNode)) { | ||
| var _ref = childNode.ref; | ||
| if (React.isValidElement(childNode) && util_1.supportRef(childNode)) { | ||
| var ref = childNode.ref; | ||
| childNodes[0] = React.cloneElement(childNode, { | ||
| ref: function ref(node) { | ||
| _this2.childNode = node; // Should forward ref | ||
| if (!_ref) { | ||
| return; | ||
| } | ||
| var type = _typeof(_ref); | ||
| if (type === 'function') { | ||
| _ref(node); | ||
| } else if (type === 'object') { | ||
| _ref.current = node; | ||
| } | ||
| } | ||
| ref: ref_1.composeRef(ref, this.setChildNode) | ||
| }); | ||
@@ -193,0 +185,0 @@ } |
+2
-2
| { | ||
| "name": "rc-resize-observer", | ||
| "version": "0.1.2", | ||
| "version": "0.1.3", | ||
| "description": "Resize observer for React", | ||
@@ -43,3 +43,3 @@ "keywords": [ | ||
| "classnames": "^2.2.1", | ||
| "rc-util": "^4.11.1", | ||
| "rc-util": "^4.13.0", | ||
| "resize-observer-polyfill": "^1.5.1" | ||
@@ -46,0 +46,0 @@ }, |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
28157
1.64%14
40%518
2.37%Updated