How to use the metal.isElement 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 / test / ComponentRenderer.js View on Github external
it('should set element to simple empty div as the default render implementation', function() {
		var component = new Component();
		renderer = new ComponentRenderer(component);
		component.emit('render');

		assert.ok(core.isElement(component.element));
		assert.strictEqual('DIV', component.element.tagName);
	});
github metal / metal.js / test / IncrementalDomAop.js View on Github external
it('should intercept attribute calls with specified function', function() {
			var original = IncrementalDomAop.getOriginalFns().attributes;
			var fn = sinon.stub();
			IncrementalDomAop.startInterception({
				attributes: fn
			});

			var element = document.createElement('div');
			IncrementalDOM.attributes[IncrementalDOM.symbols.default](element, 'name', 'value');

			assert.strictEqual(1, fn.callCount);
			assert.strictEqual(original, fn.args[0][0]);
			assert.ok(core.isElement(fn.args[0][1]));
			assert.strictEqual('name', fn.args[0][2]);
			assert.strictEqual('value', fn.args[0][3]);
		});
github liferay / senna.js / src / app / AppDataAttributeHandler.js View on Github external
handle() {
		if (!isElement(this.baseElement)) {
			throw new Error('Senna data attribute handler base element ' +
				'not set or invalid, try setting a valid element that ' +
				'contains a `data-senna` attribute.');
		}

		if (!this.baseElement.hasAttribute(dataAttributes.senna)) {
			console.log('Senna was not initialized from data attributes. ' +
				'In order to enable its usage from data attributes try setting ' +
				'in the base element, e.g. ``.');
			return;
		}

		if (this.app) {
			throw new Error('Senna app was already initialized.');
		}
github metal / metal.js / packages / metal-component / src / Component.js View on Github external
set element(val) {
		if (!isElement(val) && !isString(val) && isDefAndNotNull(val)) {
			return;
		}

		if (val) {
			val = toElement(val) || this.elementValue_;
		}

		if (this.elementValue_ !== val) {
			const prev = this.elementValue_;
			this.elementValue_ = val;
			this.handleComponentElementChanged_(prev, val);
		}
	}
github metal / metal.js / packages / metal-component / src / Component.js View on Github external
set element(val) {
		if (!isElement(val) && !isString(val) && isDefAndNotNull(val)) {
			return;
		}

		if (val) {
			val = toElement(val) || this.elementValue_;
		}

		if (this.elementValue_ !== val) {
			const prev = this.elementValue_;
			this.elementValue_ = val;
			this.handleComponentElementChanged_(prev, val);
		}
	}
github metal / metal.js / packages / metal-component / src / Component.js View on Github external
setUpPortal_(portalElement) {
		if (
			!portalElement ||
			(!isElement(portalElement) &&
				!isString(portalElement) &&
				!isBoolean(portalElement))
		) {
			return;
		} else if (isBoolean(portalElement) && portalElement) {
			portalElement = 'body';
		}

		if (isServerSide()) {
			this.portalElement = true;
			return;
		}

		portalElement = this.getPortalElement_(portalElement);

		if (portalElement) {
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 metal / metal.js / packages / metal-component / src / Component.js View on Github external
static render(Ctor, opt_configOrElement, opt_element) {
		let config = opt_configOrElement;
		let element = opt_element;
		if (isElement(opt_configOrElement)) {
			config = null;
			element = opt_configOrElement;
		}
		const instance = new Ctor(config, false);
		instance.renderComponent(element);
		return instance;
	}
github metal / metal.js / packages / metal-component / src / Component.js View on Github external
static render(Ctor, configOrElement, element) {
		let config = configOrElement;
		if (isElement(configOrElement)) {
			config = null;
			element = configOrElement;
		}
		const instance = new Ctor(config, false);
		instance.renderComponent(element);
		return instance;
	}