How to use the metal.object.mixin 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 updateContext_(comp, parent) {
	const context = comp.context;
	const childContext = parent.getChildContext
		? parent.getChildContext()
		: null; // eslint-disable-line
	object.mixin(context, parent.context, childContext);
	comp.context = context;
}
github metal / metal.js / src / SoyRenderer.js View on Github external
var component = this.component_;
		var names = component.getAttrNames().filter(function(name) {
			// Get all attribute values except for "element", since it helps performance and this
			// attribute shouldn't be referenced inside a soy template anyway.
			return name !== 'element';
		});
		var surface = this.getSurface(component.id);
		var data = (surface && surface.componentData) ? surface.componentData : {};
		var attrs = object.map(component.getAttrs(names), function(key, value) {
			if (component.getAttrConfig(key).isHtml && core.isString(value)) {
				return SoyRenderer.sanitizeHtml(value);
			} else {
				return value;
			}
		});
		return object.mixin(data, attrs);
	}
github metal / metal.js / test / IncrementalDomRenderer.js View on Github external
render() {
						IncDom.elementOpen('div');
						for (var i = 1; i <= this.count; i++) {
							IncDom.elementVoid('ChildComponent', null, ['ref', 'child' + i]);
						}
						IncDom.elementClose('div');
					}
				}
				TestComponent.RENDERER = IncrementalDomRenderer;
				TestComponent.STATE = {
					count: {
						value: 3
					}
				};
				component = new TestComponent();
				var subComps = object.mixin({}, component.components);
				assert.strictEqual(3, Object.keys(subComps).length);
				assert.ok(subComps.child1);
				assert.ok(subComps.child2);
				assert.ok(subComps.child3);

				component.count = 2;
				component.once('stateSynced', function() {
					async.nextTick(function() {
						assert.strictEqual(2, Object.keys(component.components).length);
						assert.ok(component.components.child1);
						assert.ok(component.components.child2);
						assert.ok(!component.components.child3);

						assert.ok(!subComps.child1.isDisposed());
						assert.ok(!subComps.child2.isDisposed());
						assert.ok(subComps.child3.isDisposed());
github metal / metal.js / packages / metal-state / src / State.js View on Github external
scheduleBatchEvent_(changeData) {
		if (!this.scheduledBatchData_) {
			async.nextTick(this.emitBatchEvent_, this);
			this.scheduledBatchData_ = object.mixin({
				changes: {}
			}, this.eventData_);
		}

		const name = changeData.key;
		const changes = this.scheduledBatchData_.changes;
		if (changes[name]) {
			changes[name].newVal = changeData.newVal;
		} else {
			changes[name] = changeData;
		}
	}
github LiferayCloud / marble / packages / marble-dropdown / src / Dropdown.js View on Github external
setterClassMapFn_(val) {
    return object.mixin(this.valueClassMapFn_(), val);
  }
github metal / metal.js / packages / metal-state / src / State.js View on Github external
static mergeState(mergedVal, currVal) {
		return object.mixin({}, currVal, mergedVal);
	}
github metal / metal.js / packages / metal-dom / src / domNamed.js View on Github external
export function triggerEvent(element, eventName, eventObj) {
	if (isAbleToInteractWith_(element, eventName, eventObj)) {
		const payload = document.createEvent('HTMLEvents');
		payload.initEvent(eventName, true, true);
		object.mixin(payload, eventObj);
		element.dispatchEvent(payload);
	}
}
github metal / metal.js / packages / metal-component / src / Component.js View on Github external
setUpDataManager_() {
		this.dataManager_ = getStaticProperty(this.constructor, 'DATA_MANAGER');
		this.dataManager_.setUp(
			this,
			object.mixin({}, this.renderer_.getExtraDataConfig(this), Component.DATA)
		);
	}