How to use the metal.isDefAndNotNull 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 liferay / senna.js / src / app / AppDataAttributeHandler.js View on Github external
maybeSetBasePath_() {
		var basePath = this.baseElement.getAttribute(dataAttributes.basePath);
		if (isDefAndNotNull(basePath)) {
			this.app.setBasePath(basePath);
			console.log('Senna scanned base path ' + basePath);
		}
	}
github metal / metal.js / packages / metal-state / src / State.js View on Github external
assertGivenIfRequired_(name) {
		const config = this.stateConfigs_[name];
		if (config.required) {
			const info = this.getStateInfo(name);
			const value = info.state === State.KeyStates.INITIALIZED ?
				this.get(name) :
				this.initialValues_[name];
			if (!isDefAndNotNull(value)) {
				let errorMessage = `The property called "${name}" is required but didn't receive a value.`;
				if (this.shouldThrowValidationError()) {
					throw new Error(errorMessage);
				} else {
					console.error(errorMessage);
				}
			}
		}
	}
github liferay / senna.js / src / app / App.js View on Github external
Object.keys(surfaces).forEach((id) => {
			var surfaceContent = nextScreen.getSurfaceContent(id, params);
			surfaces[id].addContent(nextScreen.getId(), surfaceContent);
			console.log('Screen [' + nextScreen.getId() + '] add content to surface ' +
				'[' + surfaces[id] + '] [' + (isDefAndNotNull(surfaceContent) ? '...' : 'empty') + ']');
		});
	}
github metal / metal.js / packages / metal-incremental-dom / src / render / render.js View on Github external
if (!getData(comp).rootElementReached) {
		const elementClasses = comp
			.getDataManager()
			.get(comp, 'elementClasses');
		if (elementClasses) {
			addElementClasses_(elementClasses, config);
		}
	}
	convertListenerNamesToFns(comp, config);

	const call = buildCallFromConfig(tag, config);
	const node = getOriginalFn('elementOpen')(...call);
	resetNodeData_(node);
	updateElementIfNotReached_(comp, node);

	if (isDefAndNotNull(config.ref)) {
		owner.refs[config.ref] = node;
	}
	owner.getRenderer().handleNodeRendered(node);

	return node;
}
github metal / metal.js / packages / metal-dom / src / domNamed.js View on Github external
export function prepend(parent, child) {
	if (isString(child)) {
		child = buildFragment(child);
	}

	if (!isNodeListLike(child) && !isDefAndNotNull(parent.firstChild)) {
		return append(parent, child);
	}

	if (isNodeListLike(child)) {
		const childArr = Array.prototype.slice.call(child);
		for (let i = childArr.length - 1; i >= 0; i--) {
			parent.insertBefore(childArr[i], parent.firstChild);
		}
	} else {
		parent.insertBefore(child, parent.firstChild);
	}

	return child;
}
github metal / metal.js / packages / metal-component / src / Component.js View on Github external
validatorEventsFn_(val) {
		return !isDefAndNotNull(val) || isObject(val);
	}
github metal / metal.js / packages / metal-incremental-dom / src / render / attributes.js View on Github external
function fixCheckedAttr_(name, value) {
	if (name === 'checked') {
		value = isDefAndNotNull(value) && value !== false;
	}
	return value;
}
github metal / metal.js / packages / metal-dom / src / domNamed.js View on Github external
export function isNodeListLike(val) {
	return (
		isDefAndNotNull(val) &&
		typeof val.length === 'number' &&
		typeof val.item === 'function'
	);
}
github liferay / senna.js / src / app / AppDataAttributeHandler.js View on Github external
maybeParseLinkRouteHandler_(link) {
		var handler = link.getAttribute('type');
		if (isDefAndNotNull(handler)) {
			handler = object.getObjectByName(handler);
		}
		return handler;
	}
github liferay / senna.js / src / surface / Surface.js View on Github external
addContent(screenId, opt_content) {
		var child = this.defaultChild;

		if (isDefAndNotNull(opt_content)) {
			child = this.getChild(screenId);
			if (child) {
				removeChildren(child);
			} else {
				child = this.createChild(screenId);
				this.transition(child, null);
			}
			append(child, opt_content);
		}

		var element = this.getElement();

		if (element && child) {
			append(element, child);
		}