How to use the metal.isDef 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-incremental-dom / src / render / render.js View on Github external
function getSubComponent_(tagOrCtor, config, owner) {
	let Ctor = tagOrCtor;
	if (isString(Ctor)) {
		Ctor = ComponentRegistry.getConstructor(tagOrCtor);
	}

	const ref = getRef_(owner, config);
	let comp;
	if (isDef(ref)) {
		comp = match_(owner.components[ref], Ctor, config, owner);
		owner.components[ref] = comp;
		owner.refs[ref] = comp;
	} else {
		const data = getCurrentData();
		let key = config.key;
		if (!isDef(key)) {
			const type = getUid(Ctor, true);
			data.currCount = data.currCount || {};
			data.currCount[type] = data.currCount[type] || 0;
			key = `__METAL_IC__${type}_${data.currCount[type]++}`;
		}
		comp = match_(
			data.prevComps ? data.prevComps[key] : null,
			Ctor,
			config,
github metal / metal.js / packages / metal-component / src / ComponentDataManager.js View on Github external
replaceNonInternal(
		component,
		data,
		state = this.getManagerData(component).state_
	) {
		const keys = state.getStateKeys();
		for (let i = 0; i < keys.length; i++) {
			const key = keys[i];
			if (!state.getStateKeyConfig(key).internal) {
				if (data.hasOwnProperty(key) && isDef(data[key])) {
					state.set(key, data[key]);
				} else {
					state.setDefaultValue(key);
				}
			}
		}
	}
github metal / metal.js / packages / metal-state / src / State.js View on Github external
hasInitialValue_(name) {
		return this.initialValues_.hasOwnProperty(name) &&
			isDef(this.initialValues_[name]);
	}
github metal / metal.js / packages / metal-dom / src / domNamed.js View on Github external
function triggerElementListeners_(element, event, defaultFns) {
	const lastContainer = event[LAST_CONTAINER];
	if (!isDef(lastContainer) || !contains(lastContainer, element)) {
		const listeners = domData.get(element, 'listeners', {})[event.type];
		return triggerListeners_(listeners, event, element, defaultFns);
	}
	return true;
}
github metal / metal.js / packages / metal-incremental-dom / src / render / render.js View on Github external
function getSubComponent_(tagOrCtor, config, owner) {
	let Ctor = tagOrCtor;
	if (isString(Ctor)) {
		Ctor = ComponentRegistry.getConstructor(tagOrCtor);
	}

	const ref = getRef_(owner, config);
	let comp;
	if (isDef(ref)) {
		comp = match_(owner.components[ref], Ctor, config, owner);
		owner.components[ref] = comp;
		owner.refs[ref] = comp;
	} else {
		const data = getCurrentData();
		let key = config.key;
		if (!isDef(key)) {
			const type = getUid(Ctor, true);
			data.currCount = data.currCount || {};
			data.currCount[type] = data.currCount[type] || 0;
			key = `__METAL_IC__${type}_${data.currCount[type]++}`;
		}
		comp = match_(
			data.prevComps ? data.prevComps[key] : null,
			Ctor,
			config,
			owner
		);
		data.currComps = data.currComps || {};
		data.currComps[key] = comp;
	}

	return comp;