Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
}
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);
}
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());
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;
}
}
setterClassMapFn_(val) {
return object.mixin(this.valueClassMapFn_(), val);
}
static mergeState(mergedVal, currVal) {
return object.mixin({}, currVal, mergedVal);
}
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);
}
}
setUpDataManager_() {
this.dataManager_ = getStaticProperty(this.constructor, 'DATA_MANAGER');
this.dataManager_.setUp(
this,
object.mixin({}, this.renderer_.getExtraDataConfig(this), Component.DATA)
);
}