Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getBindingCommand(syntax) {
const name = syntax.command;
if (name === null) {
return null;
}
let result = this.commandLookup[name];
if (result === void 0) {
result = this.resources.create(BindingCommandResource, name);
if (result == null) {
// unknown binding command
throw Reporter.error(0); // TODO: create error code
}
this.commandLookup[name] = result;
}
return result;
}
}
bind(flags, scope, binding, ...events) {
if (events.length === 0) {
throw Reporter.error(9);
}
if (binding.mode !== BindingMode.twoWay && binding.mode !== BindingMode.fromView) {
throw Reporter.error(10);
}
this.persistentFlags = flags & 2080374799 /* persistentBindingFlags */;
// ensure the binding's target observer has been set.
const targetObserver = this.observerLocator.getObserver(this.persistentFlags | flags, binding.target, binding.targetProperty);
if (!targetObserver.handler) {
throw Reporter.error(10);
}
binding.targetObserver = targetObserver;
// stash the original element subscribe function.
targetObserver.originalHandler = binding.targetObserver.handler;
// replace the element subscribe function with one that uses the correct events.
targetObserver.handler = new EventSubscriber(binding.locator.get(IDOM), events);
}
function parseForOfStatement(state, result) {
if ((result.$kind & 65536 /* IsForDeclaration */) === 0) {
throw Reporter.error(106 /* InvalidForDeclaration */, { state });
}
if (state.currentToken !== 1051179 /* OfKeyword */) {
throw Reporter.error(106 /* InvalidForDeclaration */, { state });
}
nextToken(state);
const declaration = result;
const statement = parse(state, 0 /* Reset */, 61 /* Variadic */, 0 /* None */);
return new ForOfStatement(declaration, statement);
}
/**
iterate(flags, result, func) {
switch (toStringTag.call(result)) {
case '[object Array]': return $array(flags | 8388608 /* isOriginalArray */, result, func);
case '[object Map]': return $map(flags | 8388608 /* isOriginalArray */, result, func);
case '[object Set]': return $set(flags | 8388608 /* isOriginalArray */, result, func);
case '[object Number]': return $number(flags | 8388608 /* isOriginalArray */, result, func);
case '[object Null]': return;
case '[object Undefined]': return;
default: throw Reporter.error(0); // TODO: Set error code
}
}
connect(flags, scope, binding, part) {
if (state.currentChar === 36 /* Dollar */) {
if ((state.index + 1) < state.length && state.input.charCodeAt(state.index + 1) === 123 /* OpenBrace */) {
state.index++;
tail = false;
break;
}
else {
result += '$';
}
}
else if (state.currentChar === 92 /* Backslash */) {
result += String.fromCharCode(unescapeCode(nextChar(state)));
}
else {
if (state.index >= state.length) {
throw Reporter.error(109 /* UnterminatedTemplate */, { state });
}
result += String.fromCharCode(state.currentChar);
}
}
nextChar(state);
state.tokenValue = result;
if (tail) {
return 540713 /* TemplateTail */;
}
return 540714 /* TemplateContinuation */;
}
function scanTemplateTail(state) {
* IsValidAssignmentTarget
* 1,3,4,5,6,7 = false
* 2 = true
*/
primary: switch (state.currentToken) {
case 3077 /* ParentScope */: // $parent
state.assignable = false;
do {
nextToken(state);
access++; // ancestor
if (consumeOpt(state, 16392 /* Dot */)) {
if (state.currentToken === 16392 /* Dot */) {
throw Reporter.error(102 /* DoubleDot */, { state });
}
else if (state.currentToken === 1572864 /* EOF */) {
throw Reporter.error(105 /* ExpectedIdentifier */, { state });
}
}
else if (state.currentToken & 524288 /* AccessScopeTerminal */) {
const ancestor = access & 511 /* Ancestor */;
result = ancestor === 0 ? $this : ancestor === 1 ? $parent : new AccessThisExpression(ancestor);
access = 512 /* This */;
break primary;
}
else {
throw Reporter.error(103 /* InvalidMemberExpression */, { state });
}
} while (state.currentToken === 3077 /* ParentScope */);
// falls through
case 1024 /* Identifier */: // identifier
if (bindingType & 512 /* IsIterator */) {
result = new BindingIdentifier(state.tokenValue);
function scanTemplateTail(state: ParserState): Token {
if (state.index >= state.length) {
throw Reporter.error(SyntaxError.UnterminatedTemplate, { state });
}
state.index--;
return scanTemplate(state);
}
this.sourceExpression.connect(flags, this.$scope, this);
this.unobserve(false);
}
if (Tracer.enabled) { Tracer.leave(); }
return;
}
if (flags & LifecycleFlags.updateSourceExpression) {
if (newValue !== this.sourceExpression.evaluate(flags, this.$scope, this.locator)) {
this.updateSource(newValue, flags);
}
if (Tracer.enabled) { Tracer.leave(); }
return;
}
throw Reporter.error(15, LifecycleFlags[flags]);
}
parentContext: IRenderContext | null,
componentType: ICustomElementType | null
): ITemplate {
if (parentContext === null) {
parentContext = this.container as ExposedContext;
}
if (definition.template !== null) {
const renderContext = createRenderContext(dom, parentContext, definition.dependencies, componentType) as ExposedContext;
if (definition.build.required) {
const compilerName = definition.build.compiler || defaultCompilerName;
const compiler = this.compilers[compilerName];
if (compiler === undefined) {
throw Reporter.error(20, compilerName);
}
definition = compiler.compile(dom, definition as ITemplateDefinition, new RuntimeCompilationResources(renderContext), ViewCompileFlags.surrogate);
}
return this.templateFactory.create(renderContext, definition);
}
return noViewTemplate;
}
}
private prepareMicroTaskStack(): string {
throw Reporter.error(13);
}