How to use metal-incremental-dom - 10 common examples

To help you get started, we’ve selected a few metal-incremental-dom 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-soy / src / Soy.js View on Github external
'use strict';

import 'metal-soy-bundle';
import { isFunction, isObject, isString, globals, object } from 'metal';
import { ComponentRegistry } from 'metal-component';
import HTML2IncDom from 'html2incdom';
import IncrementalDomRenderer from 'metal-incremental-dom';
import SoyAop from './SoyAop';

// The injected data that will be passed to soy templates.
let ijData = {};

class Soy extends IncrementalDomRenderer.constructor {
	/**
	 * Adds the template params to the component's state, if they don't exist yet.
	 * @param {!Component} component
	 * @return {Object}
	 */
	getExtraDataConfig(component) {
		let elementTemplate = component.constructor.TEMPLATE;
		if (!isFunction(elementTemplate)) {
			return;
		}

		elementTemplate = SoyAop.getOriginalFn(elementTemplate);
		this.soyParamTypes_ = elementTemplate.types || {};

		const keys = elementTemplate.params || [];
		const configs = {};
github metal / metal.js / packages / metal-soy / src / Soy.js View on Github external
'use strict';

import 'metal-soy-bundle';
import { ComponentRegistry } from 'metal-component';
import { isFunction, isObject, isString, object } from 'metal';
import { validators, Config } from 'metal-state';
import IncrementalDomRenderer, { HTML2IncDom } from 'metal-incremental-dom';
import SoyAop from './SoyAop';

// The injected data that will be passed to soy templates.
let ijData = {};

class Soy extends IncrementalDomRenderer.constructor {
	/**
	 * Adds the template params to the component's state, if they don't exist yet.
	 * @param {!Component} component
	 * @return {Object}
	 */
	getExtraDataConfig(component) {
		let elementTemplate = component.constructor.TEMPLATE;
		if (!isFunction(elementTemplate)) {
			return;
		}

		elementTemplate = SoyAop.getOriginalFn(elementTemplate);
		this.soyParamTypes_ = elementTemplate.types || {};

		const keys = elementTemplate.params || [];
		const configs = {};
github metal / metal.js / packages / metal-jsx / src / iDOMHelpers.js View on Github external
globals.window.iDOMHelpers.renderArbitrary = function(child) {
	const type = typeof child;
	if (type === 'number' || (type === 'string' || child && child instanceof String)) {
		IncrementalDOM.text(child);
	} else if (type === 'function' && child.__jsxDOMWrapper) {
		child();
	} else if (Array.isArray(child)) {
		child.forEach(globals.window.iDOMHelpers.renderArbitrary);
	} else if (String(child) === '[object Object]') {
		// Renders special incremental dom nodes in a special way :)
		if (IncrementalDomRenderer.isIncDomNode(child)) {
			IncrementalDomRenderer.renderChild(child);
		} else {
			globals.window.iDOMHelpers.forOwn(child, globals.window.iDOMHelpers.renderArbitrary);
		}
	} else if (!child) {
		JSXRenderer.skipChild();
	}
};
github metal / metal.js / packages / metal-jsx / src / iDOMHelpers.js View on Github external
scope.iDOMHelpers.renderArbitrary = function(child) {
	const type = typeof child;
	if (type === 'number' || (type === 'string' || child && child instanceof String)) {
		IncrementalDOM.text(child);
	} else if (type === 'function' && child.__jsxDOMWrapper) {
		child();
	} else if (Array.isArray(child)) {
		child.forEach(scope.iDOMHelpers.renderArbitrary);
	} else if (String(child) === '[object Object]') {
		// Renders special incremental dom nodes in a special way :)
		if (IncrementalDomRenderer.isIncDomNode(child)) {
			IncrementalDomRenderer.renderChild(child);
		} else {
			scope.iDOMHelpers.forOwn(child, scope.iDOMHelpers.renderArbitrary);
		}
	} else if (!child) {
		JSXRenderer.skipChild();
	}
};
github metal / metal.js / packages / metal-jsx / src / iDOMHelpers.js View on Github external
scope.iDOMHelpers.renderArbitrary = function(child) {
	const type = typeof child;
	if (type === 'number' || (type === 'string' || child && child instanceof String)) {
		IncrementalDOM.text(child);
	} else if (type === 'function' && child.__jsxDOMWrapper) {
		child();
	} else if (Array.isArray(child)) {
		child.forEach(scope.iDOMHelpers.renderArbitrary);
	} else if (String(child) === '[object Object]') {
		// Renders special incremental dom nodes in a special way :)
		if (IncrementalDomRenderer.isIncDomNode(child)) {
			IncrementalDomRenderer.renderChild(child);
		} else {
			scope.iDOMHelpers.forOwn(child, scope.iDOMHelpers.renderArbitrary);
		}
	} else if (!child) {
		JSXRenderer.skipChild();
	}
};
github metal / metal.js / packages / metal-jsx / src / iDOMHelpers.js View on Github external
globals.window.iDOMHelpers.renderArbitrary = function(child) {
	const type = typeof child;
	if (type === 'number' || (type === 'string' || child && child instanceof String)) {
		IncrementalDOM.text(child);
	} else if (type === 'function' && child.__jsxDOMWrapper) {
		child();
	} else if (Array.isArray(child)) {
		child.forEach(globals.window.iDOMHelpers.renderArbitrary);
	} else if (String(child) === '[object Object]') {
		// Renders special incremental dom nodes in a special way :)
		if (IncrementalDomRenderer.isIncDomNode(child)) {
			IncrementalDomRenderer.renderChild(child);
		} else {
			globals.window.iDOMHelpers.forOwn(child, globals.window.iDOMHelpers.renderArbitrary);
		}
	} else if (!child) {
		JSXRenderer.skipChild();
	}
};
github metal / metal.js / packages / metal-jsx / src / JSXRenderer.js View on Github external
'use strict';

import { isDefAndNotNull } from 'metal';
import IncrementalDomRenderer from 'metal-incremental-dom';

const COUNT_PROP = '__metalJsxCount';
const INC_DOM_DATA = '__incrementalDOMData';
const KEY_PREFIX = '_metal_jsx_';

/**
 * Renderer that handles JSX.
 */
class JSXRenderer extends IncrementalDomRenderer.constructor {
	/**
	 * @inheritDoc
	 */
	buildShouldUpdateArgs(changes) {
		return [changes.state, changes.props];
	}

	/**
	 * Called when generating a key for the next dom element to be created via
	 * incremental dom. Adds keys to elements that don't have one yet, according
	 * to their position in the parent. This helps use cases that use
	 * conditionally rendered elements, which is very common in JSX.
	 * @param {!Component} component
	 * @param {string} key
	 * @return {?string}
	 */
github metal / metal.js / src / JSX.js View on Github external
static render(...args) {
		return IncrementalDomRenderer.render(...args);
	}
}
github metal / metal.js / packages / metal-jsx / src / JSXComponent.js View on Github external
static render(...args) {
		return IncrementalDomRenderer.render(...args);
	}
github metal / metal.js / packages / metal-soy / src / Soy.js View on Github external
toIncDom(value) {
		if (isObject(value) && isString(value.content) && (value.contentKind === 'HTML')) {
			value = value.content;
		}
		if (isString(value)) {
			value = HTML2IncDom.buildFn(value);
		}
		return value;
	}
}

metal-incremental-dom

A Component renderer for templates compiled to incremental dom

BSD
Latest version published 4 years ago

Package Health Score

54 / 100
Full package analysis