Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function contains(element1, element2) {
if (isDocument(element1)) {
// document.contains is not defined on IE9, so call it on documentElement instead.
return element1.documentElement.contains(element2);
} else {
return element1.contains(element2);
}
}
export function toElement(selectorOrElement) {
if (
isElement(selectorOrElement) ||
isDocument(selectorOrElement) ||
isDocumentFragment(selectorOrElement)
) {
return selectorOrElement;
} else if (isString(selectorOrElement)) {
return document.querySelector(selectorOrElement);
} else {
return null;
}
}
static getSize_(node, prop) {
if (core.isWindow(node)) {
return this.getClientSize_(node, prop);
}
if (core.isDocument(node)) {
var docEl = node.documentElement;
return Math.max(
node.body['scroll' + prop], docEl['scroll' + prop],
node.body['offset' + prop], docEl['offset' + prop], docEl['client' + prop]);
}
return Math.max(node['client' + prop], node['scroll' + prop], node['offset' + prop]);
}
static getScrollLeft(node) {
if (core.isWindow(node)) {
return node.pageXOffset;
}
if (core.isDocument(node)) {
return node.defaultView.pageXOffset;
}
return node.scrollLeft;
}
static getClientSize_(node, prop) {
var el = node;
if (core.isWindow(node)) {
el = node.document.documentElement;
}
if (core.isDocument(node)) {
el = node.documentElement;
}
return el['client' + prop];
}
static getRegion(node, opt_includeScroll) {
if (core.isDocument(node) || core.isWindow(node)) {
return this.getDocumentRegion_(node);
}
return this.makeRegionFromBoundingRect_(node.getBoundingClientRect(), opt_includeScroll);
}