How to use the metal.isDocument function in metal

To help you get started, we’ve selected a few metal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github metal / metal.js / packages / metal-dom / src / domNamed.js View on Github external
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);
	}
}
github metal / metal.js / packages / metal-dom / src / domNamed.js View on Github external
export function toElement(selectorOrElement) {
	if (
		isElement(selectorOrElement) ||
		isDocument(selectorOrElement) ||
		isDocumentFragment(selectorOrElement)
	) {
		return selectorOrElement;
	} else if (isString(selectorOrElement)) {
		return document.querySelector(selectorOrElement);
	} else {
		return null;
	}
}
github deprecate / metal-position / src / Position.js View on Github external
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]);
	}
github deprecate / metal-position / src / Position.js View on Github external
static getScrollLeft(node) {
		if (core.isWindow(node)) {
			return node.pageXOffset;
		}
		if (core.isDocument(node)) {
			return node.defaultView.pageXOffset;
		}
		return node.scrollLeft;
	}
github deprecate / metal-position / src / Position.js View on Github external
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];
	}
github deprecate / metal-position / src / Position.js View on Github external
static getRegion(node, opt_includeScroll) {
		if (core.isDocument(node) || core.isWindow(node)) {
			return this.getDocumentRegion_(node);
		}
		return this.makeRegionFromBoundingRect_(node.getBoundingClientRect(), opt_includeScroll);
	}