Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected async _render(): Promise {
const env = expect(this.env, 'Unexpected missing environment during render');
// Create the template context for the root `main` template, which just
// contains the array of component roots. Any property references in that
// template will be looked up from this object.
let self = (this._self = new UpdatableReference({ roots: this._roots }));
// Create an empty root scope.
let dynamicScope = new DefaultDynamicScope();
let builder = this.builder.getBuilder(env);
let templateIterator = await this.loader.getTemplateIterator(
this,
env,
builder,
dynamicScope,
let block = bundleCompiler.preprocess(locator, state.template!);
let parsedLayout = { block, referrer: locator, asPartial: false };
let wrapped = new WrappedBuilder(parsedLayout);
bundleCompiler.addCompilableTemplate(normalizeLocator(locator), wrapped);
compileTimeModules.register(key, 'other', {
default: wrapped.symbolTable,
});
symbolTable = wrapped.symbolTable;
this.symbolTables.set(locator, symbolTable);
} else {
block = bundleCompiler.addTemplateSource(
locator,
expect(state.template, 'expected component definition state to have template')
);
symbolTable = {
hasEval: block.hasEval,
symbols: block.symbols,
};
this.symbolTables.set(locator, symbolTable);
compileTimeModules.register(key, 'other', {
default: symbolTable,
});
}
if (state.hasSymbolTable) {
registry.register(key, 'component', {
default: {
protected async _rerender() {
const env = expect(this.env, 'Unexpected missing environment during re-render');
try {
env.begin();
await this.renderer.rerender();
env.commit();
this._didRender();
} catch (err) {
this._didError(err);
}
}
private get transaction(): TransactionImpl {
return expect(this[TRANSACTION]!, 'must be in a transaction');
}
block(): Tracker {
return expect(this.blockStack.current, "Expected a current block tracker");
}
popBlock(): Tracker {
this.block().finalize(this);
return expect(this.blockStack.pop(), "Expected popBlock to return a block");
}
getCapabilities(handle: number): ComponentCapabilities {
let l = expect(
this.table.byHandle.get(handle),
`BUG: Shouldn't call getCapabilities if a handle has no associated locator`
);
let meta = expect(this.meta.get(l), `could not find template metadata for module ${l.module}`);
return this.delegate.getComponentCapabilities(meta);
}
dynamicScope(): DynamicScope {
return expect(this.dynamicScopeStack.current, 'expected dynamic scope on the dynamic scope stack');
}
willDestroy(state: Bucket): void {
expect(this.refs.get(state), 'BUG: missing ref').release();
}
lookupComponentDefinition(name: string, meta: Specifier): ComponentDefinition {
let handle: number;
if (!this.cache.component.hasName(name)) {
let specifier = expect(
this.identifyComponent(name, meta),
`Could not find the component '${name}'`
);
let template = this.owner.lookup('template', specifier);
let componentSpecifier = this.owner.identify('component', specifier);
let componentFactory: Option = null;
if (componentSpecifier !== undefined) {
componentFactory = this.owner.factoryFor(componentSpecifier);
}
handle = this.registerComponent(name, specifier, componentFactory, template);
} else {
handle = this.lookup('component', name, meta)!;
}