How to use the metal.globals.document 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 / globalEvalStyles.js View on Github external
static run(text, opt_appendFn) {
		const style = globals.document.createElement('style');
		style.innerHTML = text;
		if (opt_appendFn) {
			opt_appendFn(style);
		} else {
			globals.document.head.appendChild(style);
		}
		return style;
	}
github metal / metal.js / packages / metal-dom / src / globalEval.js View on Github external
static run(text, opt_appendFn) {
		const script = globals.document.createElement('script');
		script.text = text;
		if (opt_appendFn) {
			opt_appendFn(script);
		} else {
			globals.document.head.appendChild(script);
		}
		exitDocument(script);
		return script;
	}
github metal / metal.js / packages / metal-dom / src / features.js View on Github external
* is rendered. This method can be used to check if this behavior happens on
	 * the current browser.
	 * @return {boolean}
	 */
	static checkAttrOrderChange() {
		if (features.attrOrderChange_ === undefined) {
			const originalContent = '<div data-ref="" data-component=""></div>';
			const element = globals.document.createElement('div');
			append(element, originalContent);
			features.attrOrderChange_ = originalContent !== element.innerHTML;
		}
		return features.attrOrderChange_;
	}
}

features.animationElement_ = globals.document.createElement('div');
features.animationEventName_ = undefined;
features.attrOrderChange_ = undefined;

export default features;
github metal / metal.js / packages / metal-dom / src / globalEval.js View on Github external
static runFile(src, opt_callback, opt_appendFn) {
		const script = globals.document.createElement('script');
		script.src = src;

		const callback = function() {
			exitDocument(script);
			opt_callback && opt_callback();
		};
		once(script, 'load', callback);
		once(script, 'error', callback);

		if (opt_appendFn) {
			opt_appendFn(script);
		} else {
			globals.document.head.appendChild(script);
		}

		return script;
	}
github metal / metal.js / packages / metal-component / src / Component.js View on Github external
*/
		this.initialConfig_ = opt_config || {};

		/**
		 * Whether the element was rendered.
		 * @type {boolean}
		 */
		this.wasRendered = false;

		/**
		 * The component's element will be appended to the element this variable is
		 * set to, unless the user specifies another parent when calling `render` or
		 * `attach`.
		 * @type {!Element}
		 */
		this.DEFAULT_ELEMENT_PARENT = globals.document.body;

		this.setShouldUseFacade(true);
		this.element = this.initialConfig_.element;

		this.setUpRenderer_();
		this.setUpDataManager_();
		this.setUpSyncUpdates_();

		this.on('stateChanged', this.handleComponentStateChanged_);
		this.on('eventsChanged', this.onEventsChanged_);
		this.addListenersFromObj_(this.dataManager_.get(this, 'events'));

		this.created();
		this.componentCreated_ = true;
		if (opt_parentElement !== false) {
			this.renderComponent(opt_parentElement);
github metal / metal.js / packages / metal-dom / src / globalEvalStyles.js View on Github external
static runFile(href, opt_callback, opt_appendFn) {
		const link = globals.document.createElement('link');
		link.rel = 'stylesheet';
		link.href = href;
		globalEvalStyles.runStyle(link, opt_callback, opt_appendFn);
		return link;
	}
github metal / metal.js / packages / metal-soy / src / Soy.js View on Github external
toHtmlString(incDomFn) {
		const element = globals.document.createElement('div');
		IncrementalDOM.patch(element, incDomFn);
		return element.innerHTML;
	}
github metal / metal.js / packages / metal-component / src / ComponentRenderer.js View on Github external
render(component) {
		if (!component.element) {
			component.element = globals.document.createElement('div');
		}
		component.informRendered();
	}