Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
overflow (element) {
const parentWindow = ownerWindow(element)
const elementBounds = getBoundingClientRect(element)
const windowBounds = getBoundingClientRect(parentWindow)
const offsets = addOffsets([this.target.position, this.offset])
const parentOffset = {
top: this.element.positionedParentsOffset.top + this.element.scrollParentsOffset.top,
left: this.element.positionedParentsOffset.left + this.element.scrollParentsOffset.left
}
let left = offsets.left + parentOffset.left
let right = offsets.left + this.element.width + parentOffset.left
let top = offsets.top + parentOffset.top
let bottom = offsets.top + this.element.height + parentOffset.top
// adjust for vertical placements
if (this.element.placement[0] === "bottom") {
componentDidMount () {
const win = ownerWindow(this)
win.addEventListener('message', this.handleMessage, false)
if (super.componentDidMount) {
super.componentDidMount()
}
}
function origin (node) {
const ownWindow = ownerWindow(node)
const { location } = ownWindow
if (location.protocol === 'file:') {
return '*'
} else if (location.origin) {
return location.origin
} else if (location.port) {
return `${location.protocol}//${location.hostname}:${location.port}`
} else {
return `${location.protocol}//${location.hostname}`
}
}
get win () {
return ownerWindow(this._contextElement)
}
componentWillUnmount () {
const win = ownerWindow(this)
win.removeEventListener('message', this.handleMessage, false)
if (super.componentDidMount) {
super.componentDidMount()
}
}
const { container, constrain, placement, over } = this.options
if (!element || placement === 'offscreen') return
this.container = container || ownerDocument(element).body
this.element = new PositionedElement(element, placement, { top: this.options.offsetY, left: this.options.offsetX })
this.target = new PositionedElement(
target || this.container,
over ? this.element.placement : this.element.mirroredPlacement
)
if (constrain === 'window') {
this.constrainTo(ownerWindow(element))
} else if (constrain === 'scroll-parent') {
this.constrainTo(getScrollParents(this.target.node)[0])
} else if (constrain === 'parent') {
this.constrainTo(this.container)
} else if (typeof constrain === 'function') {
this.constrainTo(findDOMNode(constrain.call(null)))
} else if (typeof constrain === 'object') {
this.constrainTo(findDOMNode(constrain))
}
}