react-stick
Advanced tools
Comparing version 2.2.2 to 2.2.3
@@ -5,13 +5,19 @@ 'use strict'; | ||
var _react = require('react'); | ||
var _invariant = require('invariant'); | ||
var _invariant2 = _interopRequireDefault(_invariant); | ||
var _reactDom = require('react-dom'); | ||
var getBoundingClientRect = function getBoundingClientRect(instance) { | ||
// $FlowIgnore: we only allow string type components, so we will always find an Element | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function getBoundingClientRect(instance) { | ||
var element = (0, _reactDom.findDOMNode)(instance); | ||
(0, _invariant2.default)(element instanceof window.HTMLElement || element instanceof window.SVGElement, 'Cannot retrieve client rect of text or null elements'); | ||
return element.getBoundingClientRect(); | ||
}; | ||
} | ||
exports.default = getBoundingClientRect; | ||
module.exports = exports['default']; |
{ | ||
"name": "react-stick", | ||
"version": "2.2.2", | ||
"version": "2.2.3", | ||
"description": "React component to stick a portaled node to an anchor node", | ||
@@ -28,2 +28,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"invariant": "^2.2.4", | ||
"lodash": "^4.17.4", | ||
@@ -30,0 +31,0 @@ "prop-types": "^15.6.0", |
// @flow | ||
import { Component } from 'react' | ||
import invariant from 'invariant' | ||
import { findDOMNode } from 'react-dom' | ||
const getBoundingClientRect = (instance: Component<any, any>): ClientRect => { | ||
// $FlowIgnore: we only allow string type components, so we will always find an Element | ||
const element: Element = findDOMNode(instance) | ||
function getBoundingClientRect(instance: *): ClientRect { | ||
const element = findDOMNode(instance) | ||
invariant( | ||
element instanceof window.HTMLElement || | ||
element instanceof window.SVGElement, | ||
'Cannot retrieve client rect of text or null elements' | ||
) | ||
return element.getBoundingClientRect() | ||
@@ -9,0 +16,0 @@ } |
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
437433
2656
7
+ Addedinvariant@^2.2.4