Socket
Socket
Sign inDemoInstall

@fluentui/react-component-ref

Package Overview
Dependencies
10
Maintainers
8
Versions
78
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.51.0 to 0.51.1

37

dist/commonjs/RefFindNode.js

@@ -18,2 +18,21 @@ "use strict";

/**
* Detects if a passed element is a Fiber object instead of an element. Is needed as `ReactDOM.findDOMNode()` returns
* a Fiber in `react-test-renderer` that can cause issues with tests. Is used only in non-production env.
*
* @see https://github.com/facebook/react/issues/7371#issuecomment-317396864
* @see https://github.com/Semantic-Org/Semantic-UI-React/issues/4061#issuecomment-694895617
*/
function isFiberRef(node) {
if (node === null) {
return false;
}
if (node instanceof Element || node instanceof Text) {
return false;
}
return !!(node.type && node.tag);
}
var RefFindNode = /*#__PURE__*/function (_React$Component) {

@@ -37,4 +56,12 @@ (0, _inheritsLoose2.default)(RefFindNode, _React$Component);

_proto.componentDidMount = function componentDidMount() {
this.prevNode = ReactDOM.findDOMNode(this);
(0, _utils.handleRef)(this.props.innerRef, this.prevNode);
var currentNode = ReactDOM.findDOMNode(this);
if (process.env.NODE_ENV !== 'production') {
if (isFiberRef(currentNode)) {
currentNode = null;
}
}
this.prevNode = currentNode;
(0, _utils.handleRef)(this.props.innerRef, currentNode);
};

@@ -45,2 +72,8 @@

if (process.env.NODE_ENV !== 'production') {
if (isFiberRef(currentNode)) {
currentNode = null;
}
}
if (this.prevNode !== currentNode) {

@@ -47,0 +80,0 @@ this.prevNode = currentNode;

@@ -0,0 +0,0 @@ export { Ref } from './Ref';

@@ -0,0 +0,0 @@ "use strict";

import * as React from 'react';
import { RefProps } from './utils';
export declare const Ref: React.FunctionComponent<RefProps>;

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import * as React from 'react';

@@ -7,2 +7,18 @@ "use strict";

var utils_1 = require("./utils");
/**
* Detects if a passed element is a Fiber object instead of an element. Is needed as `ReactDOM.findDOMNode()` returns
* a Fiber in `react-test-renderer` that can cause issues with tests. Is used only in non-production env.
*
* @see https://github.com/facebook/react/issues/7371#issuecomment-317396864
* @see https://github.com/Semantic-Org/Semantic-UI-React/issues/4061#issuecomment-694895617
*/
function isFiberRef(node) {
if (node === null) {
return false;
}
if (node instanceof Element || node instanceof Text) {
return false;
}
return !!(node.type && node.tag);
}
var RefFindNode = /** @class */ (function (_super) {

@@ -16,7 +32,18 @@ tslib_1.__extends(RefFindNode, _super);

RefFindNode.prototype.componentDidMount = function () {
this.prevNode = ReactDOM.findDOMNode(this);
utils_1.handleRef(this.props.innerRef, this.prevNode);
var currentNode = ReactDOM.findDOMNode(this);
if (process.env.NODE_ENV !== 'production') {
if (isFiberRef(currentNode)) {
currentNode = null;
}
}
this.prevNode = currentNode;
utils_1.handleRef(this.props.innerRef, currentNode);
};
RefFindNode.prototype.componentDidUpdate = function (prevProps) {
var currentNode = ReactDOM.findDOMNode(this);
if (process.env.NODE_ENV !== 'production') {
if (isFiberRef(currentNode)) {
currentNode = null;
}
}
if (this.prevNode !== currentNode) {

@@ -23,0 +50,0 @@ this.prevNode = currentNode;

@@ -0,0 +0,0 @@ import * as React from 'react';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import * as React from 'react';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import * as React from 'react';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -6,2 +6,3 @@ "use strict";

var React = require("react");
var react_test_renderer_1 = require("react-test-renderer");
var fixtures_1 = require("./fixtures");

@@ -68,3 +69,11 @@ var testInnerRef = function (Component) {

});
it('always returns "null" for react-test-renderer', function () {
var innerRef = jest.fn();
var ref = jest.fn();
react_test_renderer_1.create(React.createElement(react_component_ref_1.RefFindNode, { innerRef: innerRef },
React.createElement("div", { ref: ref })));
expect(innerRef).toHaveBeenCalledWith(null);
expect(ref).toHaveBeenCalledWith(null);
});
});
});

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export { Ref } from './Ref';

import * as React from 'react';
import { RefProps } from './utils';
export declare const Ref: React.FunctionComponent<RefProps>;

@@ -0,0 +0,0 @@ import * as React from 'react';

import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { handleRef } from './utils';
import { handleRef } from './utils'; // ========================================================
// react/packages/react-reconciler/src/ReactFiber.js
// ========================================================
/**
* Detects if a passed element is a Fiber object instead of an element. Is needed as `ReactDOM.findDOMNode()` returns
* a Fiber in `react-test-renderer` that can cause issues with tests. Is used only in non-production env.
*
* @see https://github.com/facebook/react/issues/7371#issuecomment-317396864
* @see https://github.com/Semantic-Org/Semantic-UI-React/issues/4061#issuecomment-694895617
*/
function isFiberRef(node) {
if (node === null) {
return false;
}
if (node instanceof Element || node instanceof Text) {
return false;
}
return !!(node.type && node.tag);
}
export var RefFindNode = /*#__PURE__*/function (_React$Component) {

@@ -23,4 +45,12 @@ _inheritsLoose(RefFindNode, _React$Component);

_proto.componentDidMount = function componentDidMount() {
this.prevNode = ReactDOM.findDOMNode(this);
handleRef(this.props.innerRef, this.prevNode);
var currentNode = ReactDOM.findDOMNode(this);
if (process.env.NODE_ENV !== 'production') {
if (isFiberRef(currentNode)) {
currentNode = null;
}
}
this.prevNode = currentNode;
handleRef(this.props.innerRef, currentNode);
};

@@ -31,2 +61,8 @@

if (process.env.NODE_ENV !== 'production') {
if (isFiberRef(currentNode)) {
currentNode = null;
}
}
if (this.prevNode !== currentNode) {

@@ -33,0 +69,0 @@ this.prevNode = currentNode;

@@ -0,0 +0,0 @@ import * as React from 'react';

@@ -0,0 +0,0 @@ import * as React from 'react';

8

package.json
{
"name": "@fluentui/react-component-ref",
"description": "A set of components and utils to deal with React refs.",
"version": "0.51.0",
"version": "0.51.1",
"author": "Oleksandr Fediashov <olfedias@microsoft.com>",

@@ -19,3 +19,5 @@ "bugs": "https://github.com/microsoft/fluentui/issues",

"react": "16.8.6",
"react-dom": "16.8.6"
"react-dom": "16.8.6",
"react-test-renderer": "^16.3.0",
"typescript": "3.7.2"
},

@@ -48,3 +50,3 @@ "files": [

"types": "dist/es/index.d.ts",
"gitHead": "215aed1574db0b0db7d5fe130d19072178855423"
"gitHead": "f4f39c71f4d7af52ac8857970f6374e0bdaea1bf"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc