Compare commits

..

12 Commits

Author SHA1 Message Date
Bruno Boi 030cc2f08a wip [FIX] parser: account for CR/LF text nodes 2022-07-06 12:07:20 +02:00
Géry Debongnie 6c72e0a143 [REL] v2.0.0-beta-12
# v2.0.0-beta-12

- fix: compiler: properly handle t-set in t-if with no content
2022-06-29 11:12:59 +02:00
Géry Debongnie 382e3e4010 [FIX] compiler: properly handle t-set in t-if with no content
Before this commit, whenever Owl encounter a t-if, it generates an
anchor (a "hole") in the current block being compiled. However, in some
cases, the content of the t-if may not have any content at all, and the
anchor is then useless. Worse, the code generating the anchor generates
an index based on the number of sub blocks, but if there is no content,
the next anchor being created will have the same index, which then may
cause weird bugs.

A possible way to fix this could be to make sure we increment properly
the anchor index, but we could even do better: not having an anchor at
all.
2022-06-29 11:08:14 +02:00
Géry Debongnie 76c389a7a8 [REL] v2.0.0-beta-11
# v2.0.0-beta-11

Yet another release with some small fixes.

[FIX] fix some issues with t-out with falsy values, and with default values
[REF] app: slightly simplify the create component path
[IMP] compiler: add support for binary operators
[IMP] add support for t-call-context directive
[FIX] properly get component reference instead of context
[FIX] blockdom: fix crash when class object key has leading spaces
2022-06-28 15:28:12 +02:00
Géry Debongnie b9ba0abf41 [FIX] test: run prettier 2022-06-28 15:26:55 +02:00
Géry Debongnie 4ca37be7f3 [FIX] tests: update wrong snapshot
oups
2022-06-28 15:20:53 +02:00
Géry Debongnie d6667ddf2e [FIX] fix some issues with t-out with falsy values, and with default value 2022-06-28 15:10:11 +02:00
Géry Debongnie 6f86beeaf3 [REF] app: slightly simplify the create component path 2022-06-28 13:11:57 +02:00
Géry Debongnie 7f580a4e1d [IMP] compiler: add support for binary operators 2022-06-24 15:39:55 +02:00
Géry Debongnie c7459ef87b [IMP] add support for t-call-context directive 2022-06-22 16:15:54 +02:00
Géry Debongnie 5772b4e9e4 [FIX] properly get component reference instead of context
Before this commit, the generated code for the component directive was
using the current context as the place to look for static informations
(such as the sub components). However, it is not entirely correct, since
the current context may be different than the current component (which
is easily accessed by using the this variable).

Also, while doing this, we fix some issues in the t-set directive, which
as calling lazy values with the wrong this.
2022-06-22 16:15:54 +02:00
Samuel Degueldre e57e2ee378 [FIX] blockdom: fix crash when class object key has leading spaces
Previously, having a leading or trailing space caused
HTMLElement.classList.add to be called with an empty string (because we
are splitting on whitespace), which is not allowed and caused a crash.
This commit fixes that by trimming the keys of the class object in the
same way that we already do it for class strings.
2022-06-22 15:48:45 +02:00
60 changed files with 6524 additions and 2356 deletions
+9
View File
@@ -540,6 +540,15 @@ This can be used to define variables scoped to a sub template:
<!-- "var" does not exist here --> <!-- "var" does not exist here -->
``` ```
Note: by default, the rendering context for a sub template is simply the current
rendering context (so, the current component). However, it may be useful to be
able to specify a specific object as context. This can be done by using the
`t-call-context` directive:
```xml
<t t-call="other-template" t-call-context="obj"/>
```
### Dynamic sub templates ### Dynamic sub templates
The `t-call` directive can also be used to dynamically call a sub template, The `t-call` directive can also be used to dynamically call a sub template,
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@odoo/owl", "name": "@odoo/owl",
"version": "2.0.0-beta-10", "version": "2.0.0-beta-12",
"description": "Odoo Web Library (OWL)", "description": "Odoo Web Library (OWL)",
"main": "dist/owl.cjs.js", "main": "dist/owl.cjs.js",
"browser": "dist/owl.iife.js", "browser": "dist/owl.iife.js",
+51 -41
View File
@@ -140,9 +140,10 @@ interface Context {
tKeyExpr: string | null; tKeyExpr: string | null;
nameSpace?: string; nameSpace?: string;
tModelSelectedExpr?: string; tModelSelectedExpr?: string;
ctxVar?: string;
} }
function createContext(parentCtx: Context, params?: Partial<Context>) { function createContext(parentCtx: Context, params?: Partial<Context>): Context {
return Object.assign( return Object.assign(
{ {
block: null, block: null,
@@ -333,8 +334,8 @@ export class CodeGenerator {
this.addLine(`const ${varName} = ${expr};`); this.addLine(`const ${varName} = ${expr};`);
} }
insertAnchor(block: BlockDescription) { insertAnchor(block: BlockDescription, index: number = block.children.length) {
const tag = `block-child-${block.children.length}`; const tag = `block-child-${index}`;
const anchor = xmlDoc.createElement(tag); const anchor = xmlDoc.createElement(tag);
block.insert(anchor); block.insert(anchor);
} }
@@ -691,7 +692,7 @@ export class CodeGenerator {
const children = ast.content; const children = ast.content;
for (let i = 0; i < children.length; i++) { for (let i = 0; i < children.length; i++) {
const child = ast.content[i]; const child = ast.content[i];
const subCtx: Context = createContext(ctx, { const subCtx = createContext(ctx, {
block, block,
index: block!.childNumber, index: block!.childNumber,
forceNewBlock: false, forceNewBlock: false,
@@ -753,21 +754,37 @@ export class CodeGenerator {
this.insertAnchor(block); this.insertAnchor(block);
} }
block = this.createBlock(block, "html", ctx); block = this.createBlock(block, "html", ctx);
this.helpers.add(ast.expr === "0" ? "zero" : "safeOutput"); let blockStr;
let expr = ast.expr === "0" ? "ctx[zero]" : `safeOutput(${compileExpr(ast.expr)})`; if (ast.expr === "0") {
if (ast.body) { this.helpers.add("zero");
const nextId = BlockDescription.nextBlockId; blockStr = `ctx[zero]`;
const subCtx: Context = createContext(ctx); } else if (ast.body) {
let bodyValue = null;
bodyValue = BlockDescription.nextBlockId;
const subCtx = createContext(ctx);
this.compileAST({ type: ASTType.Multi, content: ast.body }, subCtx); this.compileAST({ type: ASTType.Multi, content: ast.body }, subCtx);
this.helpers.add("withDefault"); this.helpers.add("safeOutput");
expr = `withDefault(${expr}, b${nextId})`; blockStr = `safeOutput(${compileExpr(ast.expr)}, b${bodyValue})`;
} else {
this.helpers.add("safeOutput");
blockStr = `safeOutput(${compileExpr(ast.expr)})`;
} }
this.insertBlock(`${expr}`, block, ctx); this.insertBlock(blockStr, block, ctx);
}
compileTIfBranch(content: AST, block: BlockDescription, ctx: Context) {
this.target.indentLevel++;
let childN = block.children.length;
this.compileAST(content, createContext(ctx, { block, index: ctx.index }));
if (block.children.length > childN) {
// we have some content => need to insert an anchor at correct index
this.insertAnchor(block!, childN);
}
this.target.indentLevel--;
} }
compileTIf(ast: ASTTif, ctx: Context, nextNode?: ASTDomNode) { compileTIf(ast: ASTTif, ctx: Context, nextNode?: ASTDomNode) {
let { block, forceNewBlock, index } = ctx; let { block, forceNewBlock } = ctx;
let currentIndex = index;
const codeIdx = this.target.code.length; const codeIdx = this.target.code.length;
const isNewBlock = !block || (block.type !== "multi" && forceNewBlock); const isNewBlock = !block || (block.type !== "multi" && forceNewBlock);
if (block) { if (block) {
@@ -777,28 +794,16 @@ export class CodeGenerator {
block = this.createBlock(block, "multi", ctx); block = this.createBlock(block, "multi", ctx);
} }
this.addLine(`if (${compileExpr(ast.condition)}) {`); this.addLine(`if (${compileExpr(ast.condition)}) {`);
this.target.indentLevel++; this.compileTIfBranch(ast.content, block, ctx);
this.insertAnchor(block!);
const subCtx: Context = createContext(ctx, { block, index: currentIndex });
this.compileAST(ast.content, subCtx);
this.target.indentLevel--;
if (ast.tElif) { if (ast.tElif) {
for (let clause of ast.tElif) { for (let clause of ast.tElif) {
this.addLine(`} else if (${compileExpr(clause.condition)}) {`); this.addLine(`} else if (${compileExpr(clause.condition)}) {`);
this.target.indentLevel++; this.compileTIfBranch(clause.content, block, ctx);
this.insertAnchor(block);
const subCtx: Context = createContext(ctx, { block, index: currentIndex });
this.compileAST(clause.content, subCtx);
this.target.indentLevel--;
} }
} }
if (ast.tElse) { if (ast.tElse) {
this.addLine(`} else {`); this.addLine(`} else {`);
this.target.indentLevel++; this.compileTIfBranch(ast.tElse, block, ctx);
this.insertAnchor(block);
const subCtx: Context = createContext(ctx, { block, index: currentIndex });
this.compileAST(ast.tElse, subCtx);
this.target.indentLevel--;
} }
this.addLine("}"); this.addLine("}");
if (isNewBlock) { if (isNewBlock) {
@@ -884,7 +889,7 @@ export class CodeGenerator {
this.addLine("}"); this.addLine("}");
} }
const subCtx: Context = createContext(ctx, { block, index: loopVar }); const subCtx = createContext(ctx, { block, index: loopVar });
this.compileAST(ast.body, subCtx); this.compileAST(ast.body, subCtx);
if (ast.memo) { if (ast.memo) {
this.addLine( this.addLine(
@@ -931,7 +936,7 @@ export class CodeGenerator {
for (let i = 0, l = ast.content.length; i < l; i++) { for (let i = 0, l = ast.content.length; i < l; i++) {
const child = ast.content[i]; const child = ast.content[i];
const isTSet = child.type === ASTType.TSet; const isTSet = child.type === ASTType.TSet;
const subCtx: Context = createContext(ctx, { const subCtx = createContext(ctx, {
block, block,
index, index,
forceNewBlock: !isTSet, forceNewBlock: !isTSet,
@@ -967,16 +972,21 @@ export class CodeGenerator {
compileTCall(ast: ASTTCall, ctx: Context) { compileTCall(ast: ASTTCall, ctx: Context) {
let { block, forceNewBlock } = ctx; let { block, forceNewBlock } = ctx;
let ctxVar = ctx.ctxVar || "ctx";
if (ast.context) {
ctxVar = generateId("ctx");
this.addLine(`let ${ctxVar} = ${compileExpr(ast.context)};`);
}
if (ast.body) { if (ast.body) {
this.addLine(`ctx = Object.create(ctx);`); this.addLine(`${ctxVar} = Object.create(${ctxVar});`);
this.addLine(`ctx[isBoundary] = 1;`); this.addLine(`${ctxVar}[isBoundary] = 1;`);
this.helpers.add("isBoundary"); this.helpers.add("isBoundary");
const nextId = BlockDescription.nextBlockId; const nextId = BlockDescription.nextBlockId;
const subCtx: Context = createContext(ctx, { preventRoot: true }); const subCtx = createContext(ctx, { preventRoot: true, ctxVar });
this.compileAST({ type: ASTType.Multi, content: ast.body }, subCtx); this.compileAST({ type: ASTType.Multi, content: ast.body }, subCtx);
if (nextId !== BlockDescription.nextBlockId) { if (nextId !== BlockDescription.nextBlockId) {
this.helpers.add("zero"); this.helpers.add("zero");
this.addLine(`ctx[zero] = b${nextId};`); this.addLine(`${ctxVar}[zero] = b${nextId};`);
} }
} }
const isDynamic = INTERP_REGEXP.test(ast.name); const isDynamic = INTERP_REGEXP.test(ast.name);
@@ -994,7 +1004,7 @@ export class CodeGenerator {
} }
this.define(templateVar, subTemplate); this.define(templateVar, subTemplate);
block = this.createBlock(block, "multi", ctx); block = this.createBlock(block, "multi", ctx);
this.insertBlock(`call(this, ${templateVar}, ctx, node, ${key})`, block!, { this.insertBlock(`call(this, ${templateVar}, ${ctxVar}, node, ${key})`, block!, {
...ctx, ...ctx,
forceNewBlock: !block, forceNewBlock: !block,
}); });
@@ -1002,13 +1012,13 @@ export class CodeGenerator {
const id = generateId(`callTemplate_`); const id = generateId(`callTemplate_`);
this.staticDefs.push({ id, expr: `app.getTemplate(${subTemplate})` }); this.staticDefs.push({ id, expr: `app.getTemplate(${subTemplate})` });
block = this.createBlock(block, "multi", ctx); block = this.createBlock(block, "multi", ctx);
this.insertBlock(`${id}.call(this, ctx, node, ${key})`, block!, { this.insertBlock(`${id}.call(this, ${ctxVar}, node, ${key})`, block!, {
...ctx, ...ctx,
forceNewBlock: !block, forceNewBlock: !block,
}); });
} }
if (ast.body && !ctx.isLast) { if (ast.body && !ctx.isLast) {
this.addLine(`ctx = ctx.__proto__;`); this.addLine(`${ctxVar} = ${ctxVar}.__proto__;`);
} }
} }
@@ -1031,7 +1041,7 @@ export class CodeGenerator {
this.helpers.add("LazyValue"); this.helpers.add("LazyValue");
const bodyAst: AST = { type: ASTType.Multi, content: ast.body }; const bodyAst: AST = { type: ASTType.Multi, content: ast.body };
const name = this.compileInNewTarget("value", bodyAst, ctx); const name = this.compileInNewTarget("value", bodyAst, ctx);
let value = `new LazyValue(${name}, ctx, node)`; let value = `new LazyValue(${name}, ctx, this, node)`;
value = ast.value ? (value ? `withDefault(${expr}, ${value})` : expr) : value; value = ast.value ? (value ? `withDefault(${expr}, ${value})` : expr) : value;
this.addLine(`ctx[\`${ast.name}\`] = ${value};`); this.addLine(`ctx[\`${ast.name}\`] = ${value};`);
} else { } else {
@@ -1046,7 +1056,7 @@ export class CodeGenerator {
value = expr; value = expr;
} }
this.helpers.add("setContextValue"); this.helpers.add("setContextValue");
this.addLine(`setContextValue(ctx, "${ast.name}", ${value});`); this.addLine(`setContextValue(${ctx.ctxVar || "ctx"}, "${ast.name}", ${value});`);
} }
} }
@@ -1187,7 +1197,7 @@ export class CodeGenerator {
})`, })`,
}); });
let blockExpr = `${id}(${propString}, ${keyArg}, node, ctx, ${ast.isDynamic ? expr : null})`; let blockExpr = `${id}(${propString}, ${keyArg}, node, this, ${ast.isDynamic ? expr : null})`;
if (ast.isDynamic) { if (ast.isDynamic) {
blockExpr = `toggler(${expr}, ${blockExpr})`; blockExpr = `toggler(${expr}, ${blockExpr})`;
} }
+2 -3
View File
@@ -86,9 +86,8 @@ const STATIC_TOKEN_MAP: { [key: string]: TKind } = Object.assign(Object.create(n
// note that the space after typeof is relevant. It makes sure that the formatted // note that the space after typeof is relevant. It makes sure that the formatted
// expression has a space after typeof. Currently we don't support delete and void // expression has a space after typeof. Currently we don't support delete and void
const OPERATORS = "...,.,===,==,+,!==,!=,!,||,&&,>=,>,<=,<,?,-,*,/,%,typeof ,=>,=,;,in ,new ".split( const OPERATORS =
"," "...,.,===,==,+,!==,!=,!,||,&&,>=,>,<=,<,?,-,*,/,%,typeof ,=>,=,;,in ,new ,|,&,^,~".split(",");
);
type Tokenizer = (expr: string) => Token | false; type Tokenizer = (expr: string) => Token | false;
+7 -7
View File
@@ -115,6 +115,7 @@ export interface ASTTCall {
type: ASTType.TCall; type: ASTType.TCall;
name: string; name: string;
body: AST[] | null; body: AST[] | null;
context: string | null;
} }
interface SlotDefinition { interface SlotDefinition {
@@ -257,16 +258,12 @@ function parseTNode(node: Element, ctx: ParsingContext): AST | null {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Text and Comment Nodes // Text and Comment Nodes
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
const lineBreakRE = /[\r\n]/; const whitespaceRE = /[^\S\r\n]+/g;
const whitespaceRE = /\s+/g;
function parseTextCommentNode(node: Node, ctx: ParsingContext): AST | null { function parseTextCommentNode(node: Node, ctx: ParsingContext): AST | null {
if (node.nodeType === Node.TEXT_NODE) { if (node.nodeType === Node.TEXT_NODE) {
let value = node.textContent || ""; let value = node.textContent || "";
if (!ctx.inPreTag) { if (!ctx.inPreTag) {
if (lineBreakRE.test(value) && !value.trim()) {
return null;
}
value = value.replace(whitespaceRE, " "); value = value.replace(whitespaceRE, " ");
} }
@@ -557,11 +554,13 @@ function parseTCall(node: Element, ctx: ParsingContext): AST | null {
return null; return null;
} }
const subTemplate = node.getAttribute("t-call")!; const subTemplate = node.getAttribute("t-call")!;
const context = node.getAttribute("t-call-context");
node.removeAttribute("t-call"); node.removeAttribute("t-call");
node.removeAttribute("t-call-context");
if (node.tagName !== "t") { if (node.tagName !== "t") {
const ast = parseNode(node, ctx); const ast = parseNode(node, ctx);
const tcall: AST = { type: ASTType.TCall, name: subTemplate, body: null }; const tcall: AST = { type: ASTType.TCall, name: subTemplate, body: null, context };
if (ast && ast.type === ASTType.DomNode) { if (ast && ast.type === ASTType.DomNode) {
ast.content = [tcall]; ast.content = [tcall];
return ast; return ast;
@@ -579,6 +578,7 @@ function parseTCall(node: Element, ctx: ParsingContext): AST | null {
type: ASTType.TCall, type: ASTType.TCall,
name: subTemplate, name: subTemplate,
body: body.length ? body : null, body: body.length ? body : null,
context,
}; };
} }
+1 -5
View File
@@ -3,7 +3,6 @@ import { ComponentNode } from "./component_node";
import { nodeErrorHandlers } from "./error_handling"; import { nodeErrorHandlers } from "./error_handling";
import { Fiber, MountOptions } from "./fibers"; import { Fiber, MountOptions } from "./fibers";
import { Scheduler } from "./scheduler"; import { Scheduler } from "./scheduler";
import { STATUS } from "./status";
import { validateProps } from "./template_helpers"; import { validateProps } from "./template_helpers";
import { TemplateSet, TemplateSetConfig } from "./template_set"; import { TemplateSet, TemplateSetConfig } from "./template_set";
import { validateTarget } from "./utils"; import { validateTarget } from "./utils";
@@ -141,10 +140,7 @@ export class App<
return (props: P, key: string, ctx: ComponentNode, parent: any, C: any) => { return (props: P, key: string, ctx: ComponentNode, parent: any, C: any) => {
let children = ctx.children; let children = ctx.children;
let node: any = children[key]; let node: any = children[key];
if ( if (isDynamic && node && node.component.constructor !== C) {
node &&
(node.status === STATUS.DESTROYED || (isDynamic && node.component.constructor !== C))
) {
node = undefined; node = undefined;
} }
const parentFiber = ctx.fiber!; const parentFiber = ctx.fiber!;
+4
View File
@@ -93,6 +93,10 @@ function toClassObj(expr: string | number | { [c: string]: any }) {
for (let key in expr as any) { for (let key in expr as any) {
const value = (expr as any)[key]; const value = (expr as any)[key];
if (value) { if (value) {
key = trim.call(key);
if (!key) {
continue;
}
const words = split.call(key, wordRegexp); const words = split.call(key, wordRegexp);
for (let word of words) { for (let word of words) {
result[word] = value; result[word] = value;
+1
View File
@@ -56,6 +56,7 @@ function cancelFibers(fibers: Fiber[]): number {
fiber.render = throwOnRender; fiber.render = throwOnRender;
if (node.status === STATUS.NEW) { if (node.status === STATUS.NEW) {
node.destroy(); node.destroy();
delete node.parent!.children[node.parentKey!];
} }
node.fiber = null; node.fiber = null;
if (fiber.bdom) { if (fiber.bdom) {
+7 -5
View File
@@ -108,15 +108,17 @@ function shallowEqual(l1: any[], l2: any[]): boolean {
class LazyValue { class LazyValue {
fn: any; fn: any;
ctx: any; ctx: any;
component: any;
node: any; node: any;
constructor(fn: any, ctx: any, node: any) { constructor(fn: any, ctx: any, component: any, node: any) {
this.fn = fn; this.fn = fn;
this.ctx = capture(ctx); this.ctx = capture(ctx);
this.component = component;
this.node = node; this.node = node;
} }
evaluate(): any { evaluate(): any {
return this.fn(this.ctx, this.node); return this.fn.call(this.component, this.ctx, this.node);
} }
toString() { toString() {
@@ -127,9 +129,9 @@ class LazyValue {
/* /*
* Safely outputs `value` as a block depending on the nature of `value` * Safely outputs `value` as a block depending on the nature of `value`
*/ */
export function safeOutput(value: any): ReturnType<typeof toggler> { export function safeOutput(value: any, defaultValue?: any): ReturnType<typeof toggler> {
if (!value) { if (value === undefined) {
return value; return defaultValue ? toggler("default", defaultValue) : toggler("undefined", text(""));
} }
let safeKey; let safeKey;
let block; let block;
+29 -17
View File
@@ -57,7 +57,7 @@ exports[`Reactivity: useState destroyed component before being mounted is inacti
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; let b2;
if (ctx['state'].flag) { if (ctx['state'].flag) {
b2 = comp1({}, key + \`__1\`, node, ctx, null); b2 = comp1({}, key + \`__1\`, node, this, null);
} }
return block1([], [b2]); return block1([], [b2]);
} }
@@ -89,7 +89,7 @@ exports[`Reactivity: useState destroyed component is inactive 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; let b2;
if (ctx['state'].flag) { if (ctx['state'].flag) {
b2 = comp1({}, key + \`__1\`, node, ctx, null); b2 = comp1({}, key + \`__1\`, node, this, null);
} }
return block1([], [b2]); return block1([], [b2]);
} }
@@ -134,7 +134,7 @@ exports[`Reactivity: useState parent and children subscribed to same context 1`]
let block1 = createBlock(\`<div><block-child-0/><block-text-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/><block-text-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b2 = comp1({}, key + \`__1\`, node, this, null);
let txt1 = ctx['contextObj'].b; let txt1 = ctx['contextObj'].b;
return block1([txt1], [b2]); return block1([txt1], [b2]);
} }
@@ -228,8 +228,8 @@ exports[`Reactivity: useState two components are updated in parallel 1`] = `
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b2 = comp1({}, key + \`__1\`, node, this, null);
const b3 = comp2({}, key + \`__2\`, node, ctx, null); const b3 = comp2({}, key + \`__2\`, node, this, null);
return block1([], [b2, b3]); return block1([], [b2, b3]);
} }
}" }"
@@ -259,8 +259,8 @@ exports[`Reactivity: useState two components can subscribe to same context 1`] =
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b2 = comp1({}, key + \`__1\`, node, this, null);
const b3 = comp2({}, key + \`__2\`, node, ctx, null); const b3 = comp2({}, key + \`__2\`, node, this, null);
return block1([], [b2, b3]); return block1([], [b2, b3]);
} }
}" }"
@@ -290,8 +290,8 @@ exports[`Reactivity: useState two independent components on different levels are
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b2 = comp1({}, key + \`__1\`, node, this, null);
const b3 = comp2({}, key + \`__2\`, node, ctx, null); const b3 = comp2({}, key + \`__2\`, node, this, null);
return block1([], [b2, b3]); return block1([], [b2, b3]);
} }
}" }"
@@ -320,7 +320,7 @@ exports[`Reactivity: useState two independent components on different levels are
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b2 = comp1({}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -347,21 +347,33 @@ exports[`Reactivity: useState useless atoms should be deleted 1`] = `
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
const comp1 = app.createComponent(\`Quantity\`, true, false, false, false); const comp1 = app.createComponent(\`Quantity\`, true, false, false, false);
let block1 = createBlock(\`<div><block-child-0/> Total: <block-text-0/> Count: <block-text-1/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
Total: <block-text-0/>
Count: <block-text-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(Object.keys(ctx['state']));; const [k_block4, v_block4, l_block4, c_block4] = prepareList(Object.keys(ctx['state']));;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`id\`] = v_block2[i1]; ctx[\`id\`] = v_block4[i1];
const key1 = ctx['id']; const key1 = ctx['id'];
c_block2[i1] = withKey(comp1({id: ctx['id']}, key + \`__1__\${key1}\`, node, ctx, null), key1); const b6 = text(\`
\`);
const b7 = comp1({id: ctx['id']}, key + \`__1__\${key1}\`, node, this, null);
const b8 = text(\`
\`);
c_block4[i1] = withKey(multi([b6, b7, b8]), key1);
} }
ctx = ctx.__proto__; ctx = ctx.__proto__;
const b2 = list(c_block2); const b4 = list(c_block4);
let txt1 = ctx['total']; let txt1 = ctx['total'];
let txt2 = Object.keys(ctx['state']).length; let txt2 = Object.keys(ctx['state']).length;
return block1([txt1, txt2], [b2]); const b3 = block3([txt1, txt2], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -168,6 +168,48 @@ exports[`attributes dynamic class attribute evaluating to 0 1`] = `
}" }"
`; `;
exports[`attributes dynamic class attribute that starts and ends with a space 1`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
return function template(ctx, node, key = \\"\\") {
let attr1 = ctx['c'];
return block1([attr1]);
}
}"
`;
exports[`attributes dynamic class attribute which is only a space 1`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
return function template(ctx, node, key = \\"\\") {
let attr1 = ctx['c'];
return block1([attr1]);
}
}"
`;
exports[`attributes dynamic class attribute with multiple consecutive spaces 1`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
return function template(ctx, node, key = \\"\\") {
let attr1 = ctx['c'];
return block1([attr1]);
}
}"
`;
exports[`attributes dynamic empty class attribute 1`] = ` exports[`attributes dynamic empty class attribute 1`] = `
"function anonymous(app, bdom, helpers "function anonymous(app, bdom, helpers
) { ) {
@@ -300,14 +342,20 @@ exports[`attributes from object variables set previously 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue } = helpers; let { isBoundary, withDefault, setContextValue } = helpers;
let block1 = createBlock(\`<div><span block-attribute-0=\\"class\\"/></div>\`); let block3 = createBlock(\`<div>
<span block-attribute-0=\\"class\\"/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
setContextValue(ctx, \\"o\\", {a:'b'}); setContextValue(ctx, \\"o\\", {a:'b'});
let attr1 = ctx['o'].a; let attr1 = ctx['o'].a;
return block1([attr1]); const b3 = block3([attr1]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -318,14 +366,19 @@ exports[`attributes from variables set previously (no external node) 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue } = helpers; let { isBoundary, withDefault, setContextValue } = helpers;
let block1 = createBlock(\`<span block-attribute-0=\\"class\\"/>\`); let block4 = createBlock(\`<span block-attribute-0=\\"class\\"/>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
setContextValue(ctx, \\"abc\\", 'def'); setContextValue(ctx, \\"abc\\", 'def');
const b3 = text(\`
\`);
let attr1 = ctx['abc']; let attr1 = ctx['abc'];
return block1([attr1]); const b4 = block4([attr1]);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -470,6 +523,20 @@ exports[`attributes t-att-class with multiple classes 2`] = `
}" }"
`; `;
exports[`attributes t-att-class with multiple classes 3`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
return function template(ctx, node, key = \\"\\") {
let attr1 = {'a b c':ctx['value']};
return block1([attr1]);
}
}"
`;
exports[`attributes t-att-class with multiple classes, some of which are duplicate 1`] = ` exports[`attributes t-att-class with multiple classes, some of which are duplicate 1`] = `
"function anonymous(app, bdom, helpers "function anonymous(app, bdom, helpers
) { ) {
@@ -498,6 +565,34 @@ exports[`attributes t-att-class with object 1`] = `
}" }"
`; `;
exports[`attributes t-att-class with object 2`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
return function template(ctx, node, key = \\"\\") {
let attr1 = {' a ':ctx['value']};
return block1([attr1]);
}
}"
`;
exports[`attributes t-att-class with object 3`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
return function template(ctx, node, key = \\"\\") {
let attr1 = {' ':ctx['value']};
return block1([attr1]);
}
}"
`;
exports[`attributes t-attf-class 1`] = ` exports[`attributes t-attf-class 1`] = `
"function anonymous(app, bdom, helpers "function anonymous(app, bdom, helpers
) { ) {
@@ -629,13 +724,16 @@ exports[`attributes various escapes 1`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div foo=\\"&lt;foo\\" block-attribute-0=\\"bar\\" block-attribute-1=\\"baz\\" block-attributes=\\"2\\"/>\`); let block3 = createBlock(\`<div foo=\\"&lt;foo\\" block-attribute-0=\\"bar\\" block-attribute-1=\\"baz\\" block-attributes=\\"2\\"/>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let attr1 = ctx['bar']; let attr1 = ctx['bar'];
let attr2 = \`<\${ctx['baz']}>\`; let attr2 = \`<\${ctx['baz']}>\`;
let attr3 = ctx['qux']; let attr3 = ctx['qux'];
return block1([attr1, attr2, attr3]); const b3 = block3([attr1, attr2, attr3]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -700,11 +798,18 @@ exports[`special cases for some specific html attributes/properties select with
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<select block-attribute-0=\\"value\\"><option value=\\"potato\\">Potato</option><option value=\\"tomato\\">Tomato</option><option value=\\"onion\\">Onion</option></select>\`); let block3 = createBlock(\`<select block-attribute-0=\\"value\\">
<option value=\\"potato\\">Potato</option>
<option value=\\"tomato\\">Tomato</option>
<option value=\\"onion\\">Onion</option>
</select>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let attr1 = ctx['value']; let attr1 = ctx['value'];
return block1([attr1]); const b3 = block3([attr1]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -728,10 +833,23 @@ exports[`special cases for some specific html attributes/properties various bool
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><input type=\\"checkbox\\" checked=\\"checked\\"/><input checked=\\"checked\\"/><div checked=\\"checked\\"/><div selected=\\"selected\\"/><option selected=\\"selected\\" other=\\"1\\"/><input readonly=\\"readonly\\"/><button disabled=\\"disabled\\"/></div>\`); let block3 = createBlock(\`<div>
<input type=\\"checkbox\\" checked=\\"checked\\"/>
<input checked=\\"checked\\"/>
<div checked=\\"checked\\"/>
<div selected=\\"selected\\"/>
<option selected=\\"selected\\" other=\\"1\\"/>
<input readonly=\\"readonly\\"/>
<button disabled=\\"disabled\\"/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return block1(); const b2 = text(\`
\`);
const b3 = block3();
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -29,18 +29,23 @@ exports[`comments properly handle comments between t-if/t-else 1`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); let block3 = createBlock(\`<div>
let block2 = createBlock(\`<span>true</span>\`); <block-child-0/><block-child-1/>
let block3 = createBlock(\`<span>owl</span>\`); </div>\`);
let block4 = createBlock(\`<span>true</span>\`);
let block5 = createBlock(\`<span>owl</span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; const b2 = text(\`
\`);
let b4,b5;
if (true) { if (true) {
b2 = block2(); b4 = block4();
} else { } else {
b3 = block3(); b5 = block5();
} }
return block1([], [b2, b3]); const b3 = block3([], [b4, b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -65,23 +65,31 @@ exports[`t-on can bind handlers with empty object (with non empty inner string)
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
let block1 = createBlock(\`<ul><block-child-0/></ul>\`); let block3 = createBlock(\`<ul>
let block3 = createBlock(\`<li><a block-handler-0=\\"click\\">link</a></li>\`); <block-child-0/>
</ul>\`);
let block5 = createBlock(\`<li>
<a block-handler-0=\\"click\\">link</a>
</li>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(['someval']);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(['someval']);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`action\`] = v_block2[i1]; ctx[\`action\`] = v_block4[i1];
ctx[\`action_index\`] = i1; ctx[\`action_index\`] = i1;
const key1 = ctx['action_index']; const key1 = ctx['action_index'];
const v1 = ctx['activate']; const v1 = ctx['activate'];
const v2 = ctx['action']; const v2 = ctx['action'];
let hdlr1 = [()=>v1(v2), ctx]; let hdlr1 = [()=>v1(v2), ctx];
c_block2[i1] = withKey(block3([hdlr1]), key1); c_block4[i1] = withKey(block5([hdlr1]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -106,12 +114,15 @@ exports[`t-on can bind two event handlers 1`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<button block-handler-0=\\"click\\" block-handler-1=\\"dblclick\\">Click</button>\`); let block3 = createBlock(\`<button block-handler-0=\\"click\\" block-handler-1=\\"dblclick\\">Click</button>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let hdlr1 = [ctx['handleClick'], ctx]; let hdlr1 = [ctx['handleClick'], ctx];
let hdlr2 = [ctx['handleDblClick'], ctx]; let hdlr2 = [ctx['handleDblClick'], ctx];
return block1([hdlr1, hdlr2]); const b3 = block3([hdlr1, hdlr2]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -136,18 +147,26 @@ exports[`t-on handler is bound to proper owner, part 2 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
let block2 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`); let block6 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block1, v_block1, l_block1, c_block1] = prepareList([1]);; const [k_block3, v_block3, l_block3, c_block3] = prepareList([1]);;
for (let i1 = 0; i1 < l_block1; i1++) { for (let i1 = 0; i1 < l_block3; i1++) {
ctx[\`value\`] = v_block1[i1]; ctx[\`value\`] = v_block3[i1];
const key1 = ctx['value']; const key1 = ctx['value'];
const b5 = text(\`
\`);
let hdlr1 = [ctx['add'], ctx]; let hdlr1 = [ctx['add'], ctx];
c_block1[i1] = withKey(block2([hdlr1]), key1); const b6 = block6([hdlr1]);
const b7 = text(\`
\`);
c_block3[i1] = withKey(multi([b5, b6, b7]), key1);
} }
return list(c_block1); const b3 = list(c_block3);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -186,18 +205,26 @@ exports[`t-on handler is bound to proper owner, part 4 1`] = `
const callTemplate_1 = app.getTemplate(\`sub\`); const callTemplate_1 = app.getTemplate(\`sub\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block1, v_block1, l_block1, c_block1] = prepareList([1]);; const [k_block3, v_block3, l_block3, c_block3] = prepareList([1]);;
for (let i1 = 0; i1 < l_block1; i1++) { for (let i1 = 0; i1 < l_block3; i1++) {
ctx[\`value\`] = v_block1[i1]; ctx[\`value\`] = v_block3[i1];
ctx[\`value_first\`] = i1 === 0; ctx[\`value_first\`] = i1 === 0;
ctx[\`value_last\`] = i1 === v_block1.length - 1; ctx[\`value_last\`] = i1 === v_block3.length - 1;
ctx[\`value_index\`] = i1; ctx[\`value_index\`] = i1;
ctx[\`value_value\`] = k_block1[i1]; ctx[\`value_value\`] = k_block3[i1];
const key1 = ctx['value']; const key1 = ctx['value'];
c_block1[i1] = withKey(callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`), key1); const b5 = text(\`
\`);
const b6 = callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`);
const b7 = text(\`
\`);
c_block3[i1] = withKey(multi([b5, b6, b7]), key1);
} }
return list(c_block1); const b3 = list(c_block3);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -235,7 +262,9 @@ exports[`t-on t-on modifiers (native listener) basic support for native listener
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div class=\\"myClass\\" block-handler-0=\\"click\\"><button block-handler-1=\\"click\\">Button</button></div>\`); let block1 = createBlock(\`<div class=\\"myClass\\" block-handler-0=\\"click\\">
<button block-handler-1=\\"click\\">Button</button>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let hdlr1 = [ctx['divClicked'], ctx]; let hdlr1 = [ctx['divClicked'], ctx];
@@ -281,7 +310,9 @@ exports[`t-on t-on modifiers (native listener) t-on with .capture modifier 1`] =
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div block-handler-0=\\"click.capture\\"><button block-handler-1=\\"click\\">Button</button></div>\`); let block1 = createBlock(\`<div block-handler-0=\\"click.capture\\">
<button block-handler-1=\\"click\\">Button</button>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let hdlr1 = [\\"capture\\", ctx['onCapture'], ctx]; let hdlr1 = [\\"capture\\", ctx['onCapture'], ctx];
@@ -296,7 +327,9 @@ exports[`t-on t-on modifiers (native listener) t-on with empty handler (only mod
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><button block-handler-0=\\"click.prevent\\">Button</button></div>\`); let block1 = createBlock(\`<div>
<button block-handler-0=\\"click.prevent\\">Button</button>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let hdlr1 = [\\"prevent\\", , ctx]; let hdlr1 = [\\"prevent\\", , ctx];
@@ -310,7 +343,9 @@ exports[`t-on t-on modifiers (native listener) t-on with prevent and self modifi
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><button block-handler-0=\\"click.prevent.self\\"><span>Button</span></button></div>\`); let block1 = createBlock(\`<div>
<button block-handler-0=\\"click.prevent.self\\"><span>Button</span></button>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let hdlr1 = [\\"prevent\\",\\"self\\", ctx['onClick'], ctx]; let hdlr1 = [\\"prevent\\",\\"self\\", ctx['onClick'], ctx];
@@ -324,7 +359,11 @@ exports[`t-on t-on modifiers (native listener) t-on with prevent and/or stop mod
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><button block-handler-0=\\"click.prevent\\">Button 1</button><button block-handler-1=\\"click.stop\\">Button 2</button><button block-handler-2=\\"click.prevent.stop\\">Button 3</button></div>\`); let block1 = createBlock(\`<div>
<button block-handler-0=\\"click.prevent\\">Button 1</button>
<button block-handler-1=\\"click.stop\\">Button 2</button>
<button block-handler-2=\\"click.prevent.stop\\">Button 3</button>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let hdlr1 = [\\"prevent\\", ctx['onClickPrevented'], ctx]; let hdlr1 = [\\"prevent\\", ctx['onClickPrevented'], ctx];
@@ -341,8 +380,12 @@ exports[`t-on t-on modifiers (native listener) t-on with prevent modifier in t-f
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div>
let block3 = createBlock(\`<a href=\\"#\\" block-handler-0=\\"click.prevent\\"> Edit <block-text-1/></a>\`); <block-child-0/>
</div>\`);
let block5 = createBlock(\`<a href=\\"#\\" block-handler-0=\\"click.prevent\\">
Edit <block-text-1/>
</a>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
@@ -350,12 +393,18 @@ exports[`t-on t-on modifiers (native listener) t-on with prevent modifier in t-f
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block2; i1++) {
ctx[\`project\`] = v_block2[i1]; ctx[\`project\`] = v_block2[i1];
const key1 = ctx['project']; const key1 = ctx['project'];
const b4 = text(\`
\`);
const v1 = ctx['onEdit']; const v1 = ctx['onEdit'];
const v2 = ctx['project']; const v2 = ctx['project'];
let hdlr1 = [\\"prevent\\", _ev=>v1(v2.id,_ev), ctx]; let hdlr1 = [\\"prevent\\", _ev=>v1(v2.id,_ev), ctx];
let txt1 = ctx['project'].name; let txt1 = ctx['project'].name;
c_block2[i1] = withKey(block3([hdlr1, txt1]), key1); const b5 = block5([hdlr1, txt1]);
const b6 = text(\`
\`);
c_block2[i1] = withKey(multi([b4, b5, b6]), key1);
} }
ctx = ctx.__proto__;
const b2 = list(c_block2); const b2 = list(c_block2);
return block1([], [b2]); return block1([], [b2]);
} }
@@ -367,7 +416,9 @@ exports[`t-on t-on modifiers (native listener) t-on with self and prevent modifi
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><button block-handler-0=\\"click.self.prevent\\"><span>Button</span></button></div>\`); let block1 = createBlock(\`<div>
<button block-handler-0=\\"click.self.prevent\\"><span>Button</span></button>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let hdlr1 = [\\"self\\",\\"prevent\\", ctx['onClick'], ctx]; let hdlr1 = [\\"self\\",\\"prevent\\", ctx['onClick'], ctx];
@@ -381,7 +432,10 @@ exports[`t-on t-on modifiers (native listener) t-on with self modifier 1`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><button block-handler-0=\\"click\\"><span>Button</span></button><button block-handler-1=\\"click.self\\"><span>Button</span></button></div>\`); let block1 = createBlock(\`<div>
<button block-handler-0=\\"click\\"><span>Button</span></button>
<button block-handler-1=\\"click.self\\"><span>Button</span></button>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let hdlr1 = [ctx['onClick'], ctx]; let hdlr1 = [ctx['onClick'], ctx];
@@ -396,7 +450,9 @@ exports[`t-on t-on modifiers (synthetic listener) basic support for synthetic 1`
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div block-handler-0=\\"click.synthetic\\"><button block-handler-1=\\"click.synthetic\\">Button</button></div>\`); let block1 = createBlock(\`<div block-handler-0=\\"click.synthetic\\">
<button block-handler-1=\\"click.synthetic\\">Button</button>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let hdlr1 = [\\"synthetic\\", ctx['divClicked'], ctx]; let hdlr1 = [\\"synthetic\\", ctx['divClicked'], ctx];
+320 -109
View File
@@ -7,74 +7,116 @@ exports[`misc complex template 1`] = `
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
const comp1 = app.createComponent(\`SlotButton\`, true, false, false, false); const comp1 = app.createComponent(\`SlotButton\`, true, false, false, false);
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"><div block-attribute-1=\\"class\\"><div class=\\"batch_header\\"><a block-attribute-2=\\"href\\" block-attribute-3=\\"class\\" title=\\"View Batch\\"><block-text-4/><block-child-0/><i class=\\"arrow fa fa-window-maximize\\"/></a></div><block-child-1/><div class=\\"batch_slots\\"><block-child-2/><block-child-3/></div><div class=\\"batch_commits\\"><block-child-4/></div></div></div>\`); let block3 = createBlock(\`<div block-attribute-0=\\"class\\">
let block2 = createBlock(\`<i class=\\"fa fa-exclamation-triangle\\"/>\`); <div block-attribute-1=\\"class\\">
let block3 = createBlock(\`<span><i class=\\"fa fa-cog fa-spin fa-fw\\"/> preparing</span>\`); <div class=\\"batch_header\\">
let block7 = createBlock(\`<div class=\\"slot_filler\\"/>\`); <a block-attribute-2=\\"href\\" block-attribute-3=\\"class\\" title=\\"View Batch\\">
let block9 = createBlock(\`<div class=\\"one_line\\"><a block-attribute-0=\\"href\\" block-attribute-1=\\"class\\"><block-child-0/><block-child-1/><block-child-2/><block-child-3/><block-text-2/></a><a block-attribute-3=\\"href\\" class=\\"badge badge-light\\" title=\\"View Commit on Github\\"><i class=\\"fa fa-github\\"/></a><span><block-text-4/></span></div>\`); <block-text-4/>
let block10 = createBlock(\`<i class=\\"fa fa-fw fa-hashtag\\" title=\\"This commit is a new head\\"/>\`); <block-child-0/>
let block11 = createBlock(\`<i class=\\"fa fa-fw fa-link\\" title=\\"This commit is an existing head from bundle branches\\"/>\`); <i class=\\"arrow fa fa-window-maximize\\"/>
let block12 = createBlock(\`<i class=\\"fa fa-fw fa-code-fork\\" title=\\"This commit is matched from a base batch with matching merge_base\\"/>\`); </a>
let block13 = createBlock(\`<i class=\\"fa fa-fw fa-clock-o\\" title=\\"This commit is the head of a base branch\\"/>\`); </div>
<block-child-1/>
<div class=\\"batch_slots\\">
<block-child-2/>
<block-child-3/>
</div>
<div class=\\"batch_commits\\">
<block-child-4/>
</div>
</div>
</div>\`);
let block4 = createBlock(\`<i class=\\"fa fa-exclamation-triangle\\"/>\`);
let block7 = createBlock(\`<span><i class=\\"fa fa-cog fa-spin fa-fw\\"/> preparing</span>\`);
let block15 = createBlock(\`<div class=\\"slot_filler\\"/>\`);
let block17 = createBlock(\`<div class=\\"one_line\\">
<a block-attribute-0=\\"href\\" block-attribute-1=\\"class\\">
<block-child-0/>
<block-child-1/>
<block-child-2/>
<block-child-3/>
<block-text-2/>
</a>
<a block-attribute-3=\\"href\\" class=\\"badge badge-light\\" title=\\"View Commit on Github\\"><i class=\\"fa fa-github\\"/></a>
<span><block-text-4/></span>
</div>\`);
let block18 = createBlock(\`<i class=\\"fa fa-fw fa-hashtag\\" title=\\"This commit is a new head\\"/>\`);
let block19 = createBlock(\`<i class=\\"fa fa-fw fa-link\\" title=\\"This commit is an existing head from bundle branches\\"/>\`);
let block20 = createBlock(\`<i class=\\"fa fa-fw fa-code-fork\\" title=\\"This commit is matched from a base batch with matching merge_base\\"/>\`);
let block21 = createBlock(\`<i class=\\"fa fa-fw fa-clock-o\\" title=\\"This commit is the head of a base branch\\"/>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3,b4,b6,b8; const b2 = text(\`
\`);
let b4,b5,b9,b14,b16;
let attr1 = \`batch_tile \${ctx['options'].more?'more':'nomore'}\`; let attr1 = \`batch_tile \${ctx['options'].more?'more':'nomore'}\`;
let attr2 = \`card bg-\${ctx['klass']}-light\`; let attr2 = \`card bg-\${ctx['klass']}-light\`;
let attr3 = \`/runbot/batch/\${ctx['batch'].id}\`; let attr3 = \`/runbot/batch/\${ctx['batch'].id}\`;
let attr4 = \`badge badge-\${ctx['batch'].has_warning?'warning':'light'}\`; let attr4 = \`badge badge-\${ctx['batch'].has_warning?'warning':'light'}\`;
let txt1 = ctx['batch'].formated_age; let txt1 = ctx['batch'].formated_age;
if (ctx['batch'].has_warning) { if (ctx['batch'].has_warning) {
b2 = block2(); b4 = block4();
} }
if (ctx['batch'].state=='preparing') { if (ctx['batch'].state=='preparing') {
b3 = block3(); const b6 = text(\`
\`);
const b7 = block7();
const b8 = text(\`
\`);
b5 = multi([b6, b7, b8]);
} }
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['batch'].slot_ids.filter(_slot=>_slot.build_id.id&&!_slot.trigger_id.manual&&(ctx['options'].trigger_display[_slot.trigger_id.id])));; const [k_block9, v_block9, l_block9, c_block9] = prepareList(ctx['batch'].slot_ids.filter(_slot=>_slot.build_id.id&&!_slot.trigger_id.manual&&(ctx['options'].trigger_display[_slot.trigger_id.id])));;
for (let i1 = 0; i1 < l_block4; i1++) { for (let i1 = 0; i1 < l_block9; i1++) {
ctx[\`slot\`] = v_block4[i1]; ctx[\`slot\`] = v_block9[i1];
const key1 = ctx['slot'].id; const key1 = ctx['slot'].id;
c_block4[i1] = withKey(comp1({class: ctx['slot_container'],slot: ctx['slot']}, key + \`__1__\${key1}\`, node, ctx, null), key1); const b11 = text(\`
\`);
const b12 = comp1({class: ctx['slot_container'],slot: ctx['slot']}, key + \`__1__\${key1}\`, node, this, null);
const b13 = text(\`
\`);
c_block9[i1] = withKey(multi([b11, b12, b13]), key1);
} }
ctx = ctx.__proto__; ctx = ctx.__proto__;
b4 = list(c_block4); b9 = list(c_block9);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block6, v_block6, l_block6, c_block6] = prepareList([1,2,3,4]);; const [k_block14, v_block14, l_block14, c_block14] = prepareList([1,2,3,4]);;
for (let i1 = 0; i1 < l_block6; i1++) { for (let i1 = 0; i1 < l_block14; i1++) {
ctx[\`x\`] = v_block6[i1]; ctx[\`x\`] = v_block14[i1];
const key1 = ctx['x']; const key1 = ctx['x'];
c_block6[i1] = withKey(block7(), key1); c_block14[i1] = withKey(block15(), key1);
} }
ctx = ctx.__proto__; ctx = ctx.__proto__;
b6 = list(c_block6); b14 = list(c_block14);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block8, v_block8, l_block8, c_block8] = prepareList(ctx['commit_links']);; const [k_block16, v_block16, l_block16, c_block16] = prepareList(ctx['commit_links']);;
for (let i1 = 0; i1 < l_block8; i1++) { for (let i1 = 0; i1 < l_block16; i1++) {
ctx[\`commit_link\`] = v_block8[i1]; ctx[\`commit_link\`] = v_block16[i1];
const key1 = ctx['commit_link'].id; const key1 = ctx['commit_link'].id;
let b10,b11,b12,b13; let b18,b19,b20,b21;
let attr5 = \`/runbot/commit/\${ctx['commit_link'].commit_id}\`; let attr5 = \`/runbot/commit/\${ctx['commit_link'].commit_id}\`;
let attr6 = \`badge badge-light batch_commit match_type_\${ctx['commit_link'].match_type}\`; let attr6 = \`badge badge-light batch_commit match_type_\${ctx['commit_link'].match_type}\`;
if (ctx['commit_link'].match_type=='new') { if (ctx['commit_link'].match_type=='new') {
b10 = block10(); b18 = block18();
} }
if (ctx['commit_link'].match_type=='head') { if (ctx['commit_link'].match_type=='head') {
b11 = block11(); b19 = block19();
} }
if (ctx['commit_link'].match_type=='base_match') { if (ctx['commit_link'].match_type=='base_match') {
b12 = block12(); b20 = block20();
} }
if (ctx['commit_link'].match_type=='base_head') { if (ctx['commit_link'].match_type=='base_head') {
b13 = block13(); b21 = block21();
} }
let txt2 = ctx['commit_link'].commit_dname; let txt2 = ctx['commit_link'].commit_dname;
let attr7 = 'https://%s/commit/%s'%(ctx['commit_link'].commit_remote_url,ctx['commit_link'].commit_name); let attr7 = 'https://%s/commit/%s'%(ctx['commit_link'].commit_remote_url,ctx['commit_link'].commit_name);
let txt3 = ctx['commit_link'].commit_subject; let txt3 = ctx['commit_link'].commit_subject;
c_block8[i1] = withKey(block9([attr5, attr6, txt2, attr7, txt3], [b10, b11, b12, b13]), key1); c_block16[i1] = withKey(block17([attr5, attr6, txt2, attr7, txt3], [b18, b19, b20, b21]), key1);
} }
b8 = list(c_block8); ctx = ctx.__proto__;
return block1([attr1, attr2, attr3, attr4, txt1], [b2, b3, b4, b6, b8]); b16 = list(c_block16);
const b3 = block3([attr1, attr2, attr3, attr4, txt1], [b4, b5, b9, b14, b16]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -90,43 +132,71 @@ exports[`misc global 1`] = `
const callTemplate_4 = app.getTemplate(\`_callee-asc\`); const callTemplate_4 = app.getTemplate(\`_callee-asc\`);
const callTemplate_5 = app.getTemplate(\`_callee-asc-toto\`); const callTemplate_5 = app.getTemplate(\`_callee-asc-toto\`);
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); let block3 = createBlock(\`<div>
let block4 = createBlock(\`<span><block-text-0/></span>\`); <block-child-0/>
<block-child-1/>
</div>\`);
let block7 = createBlock(\`<span><block-text-0/></span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList([4,5,6]);; const [k_block4, v_block4, l_block4, c_block4] = prepareList([4,5,6]);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`value\`] = v_block2[i1]; ctx[\`value\`] = v_block4[i1];
ctx[\`value_first\`] = i1 === 0; ctx[\`value_first\`] = i1 === 0;
ctx[\`value_last\`] = i1 === v_block2.length - 1; ctx[\`value_last\`] = i1 === v_block4.length - 1;
ctx[\`value_index\`] = i1; ctx[\`value_index\`] = i1;
ctx[\`value_value\`] = k_block2[i1]; ctx[\`value_value\`] = k_block4[i1];
const key1 = ctx['value']; const key1 = ctx['value'];
const b6 = text(\`
\`);
let txt1 = ctx['value']; let txt1 = ctx['value'];
const b4 = block4([txt1]); const b7 = block7([txt1]);
const b8 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1; ctx[isBoundary] = 1;
const b10 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1; ctx[isBoundary] = 1;
const b12 = text(\`
\`);
setContextValue(ctx, \\"foo\\", 'aaa'); setContextValue(ctx, \\"foo\\", 'aaa');
const b6 = callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`); const b13 = text(\`
\`);
const b11 = multi([b12, b13]);
ctx[zero] = b11;
const b14 = callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`);
ctx = ctx.__proto__; ctx = ctx.__proto__;
const b7 = callTemplate_2.call(this, ctx, node, key + \`__2__\${key1}\`); const b15 = text(\`
\`);
const b16 = callTemplate_2.call(this, ctx, node, key + \`__2__\${key1}\`);
const b17 = text(\`
\`);
setContextValue(ctx, \\"foo\\", 'bbb'); setContextValue(ctx, \\"foo\\", 'bbb');
const b8 = callTemplate_3.call(this, ctx, node, key + \`__3__\${key1}\`); const b18 = text(\`
const b5 = multi([b6, b7, b8]); \`);
ctx[zero] = b5; const b19 = callTemplate_3.call(this, ctx, node, key + \`__3__\${key1}\`);
const b9 = callTemplate_4.call(this, ctx, node, key + \`__4__\${key1}\`); const b20 = text(\`
\`);
const b9 = multi([b10, b14, b15, b16, b17, b18, b19, b20]);
ctx[zero] = b9;
const b21 = callTemplate_4.call(this, ctx, node, key + \`__4__\${key1}\`);
ctx = ctx.__proto__; ctx = ctx.__proto__;
c_block2[i1] = withKey(multi([b4, b9]), key1); const b22 = text(\`
\`);
c_block4[i1] = withKey(multi([b6, b7, b8, b21, b22]), key1);
} }
ctx = ctx.__proto__; ctx = ctx.__proto__;
const b2 = list(c_block2); const b4 = list(c_block4);
const b10 = callTemplate_5.call(this, ctx, node, key + \`__5\`); const b23 = callTemplate_5.call(this, ctx, node, key + \`__5\`);
return block1([], [b2, b10]); const b3 = block3([], [b4, b23]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -166,13 +236,13 @@ exports[`misc global 4`] = `
"function anonymous(app, bdom, helpers "function anonymous(app, bdom, helpers
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { safeOutput, withDefault } = helpers; let { safeOutput } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b3 = text(\`toto default\`); const b3 = text(\`toto default\`);
const b2 = withDefault(safeOutput(ctx['toto']), b3); const b2 = safeOutput(ctx['toto'], b3);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -187,7 +257,48 @@ exports[`misc other complex template 1`] = `
const comp1 = app.createComponent(\`BundlesList\`, true, false, false, false); const comp1 = app.createComponent(\`BundlesList\`, true, false, false, false);
const comp2 = app.createComponent(\`BundlesList\`, true, false, false, false); const comp2 = app.createComponent(\`BundlesList\`, true, false, false, false);
let block1 = createBlock(\`<div><header><nav class=\\"navbar navbar-expand-md navbar-light bg-light\\"><a block-attribute-0=\\"href\\"><b style=\\"color:#777;\\"><block-text-1/></b></a><button type=\\"button\\" class=\\"navbar-toggler\\" data-toggle=\\"collapse\\" data-target=\\"#top_menu_collapse\\"><span class=\\"navbar-toggler-icon\\"/></button><div class=\\"collapse navbar-collapse\\" id=\\"top_menu_collapse\\" aria-expanded=\\"false\\"><ul class=\\"nav navbar-nav ml-auto text-right\\" id=\\"top_menu\\"><block-child-0/><li class=\\"nav-item divider\\"/><block-child-1/></ul><div><div class=\\"input-group input-group-sm\\"><div class=\\"input-group-prepend input-group-sm\\"><button class=\\"btn btn-default fa fa-cog\\" title=\\"Settings\\" block-handler-2=\\"click\\"/><button class=\\"btn btn-default\\" block-handler-3=\\"click\\"> More </button><block-child-2/></div><input class=\\"form-control\\" type=\\"text\\" placeholder=\\"Search\\" aria-label=\\"Search\\" name=\\"search\\" block-attribute-4=\\"value\\" block-handler-5=\\"keyup\\" block-handler-6=\\"change\\" block-ref=\\"7\\"/><div class=\\"input-group-append\\"><button class=\\"btn btn-default fa fa-eraser\\" block-handler-8=\\"click\\"/></div></div></div></div></nav></header><div class=\\"container-fluid\\" block-ref=\\"9\\"><div class=\\"row\\"><!--div class=\\"form-group col-md-6\\"> let block3 = createBlock(\`<div>
<header>
<nav class=\\"navbar navbar-expand-md navbar-light bg-light\\">
<a block-attribute-0=\\"href\\">
<b style=\\"color:#777;\\">
<block-text-1/>
</b>
</a>
<button type=\\"button\\" class=\\"navbar-toggler\\" data-toggle=\\"collapse\\" data-target=\\"#top_menu_collapse\\">
<span class=\\"navbar-toggler-icon\\"/>
</button>
<div class=\\"collapse navbar-collapse\\" id=\\"top_menu_collapse\\" aria-expanded=\\"false\\">
<ul class=\\"nav navbar-nav ml-auto text-right\\" id=\\"top_menu\\">
<block-child-0/>
<li class=\\"nav-item divider\\"/>
<block-child-1/>
</ul>
<div>
<div class=\\"input-group input-group-sm\\">
<div class=\\"input-group-prepend input-group-sm\\">
<button class=\\"btn btn-default fa fa-cog\\" title=\\"Settings\\" block-handler-2=\\"click\\"/>
<button class=\\"btn btn-default\\" block-handler-3=\\"click\\">
More
</button>
<block-child-2/>
</div>
<input class=\\"form-control\\" type=\\"text\\" placeholder=\\"Search\\" aria-label=\\"Search\\" name=\\"search\\" block-attribute-4=\\"value\\" block-handler-5=\\"keyup\\" block-handler-6=\\"change\\" block-ref=\\"7\\"/>
<div class=\\"input-group-append\\">
<button class=\\"btn btn-default fa fa-eraser\\" block-handler-8=\\"click\\"/>
</div>
</div>
</div>
</div>
</nav>
</header>
<div class=\\"container-fluid\\" block-ref=\\"9\\">
<div class=\\"row\\">
<!--div class=\\"form-group col-md-6\\">
<h5>Search options</h5> <h5>Search options</h5>
<input class=\\"form-control\\" type=\\"text\\" name=\\"default_search\\" id=\\"default_search\\" t-att-checked=\\"default_search\\" placeholder=\\"Default search\\"/> <input class=\\"form-control\\" type=\\"text\\" name=\\"default_search\\" id=\\"default_search\\" t-att-checked=\\"default_search\\" placeholder=\\"Default search\\"/>
@@ -200,94 +311,187 @@ exports[`misc other complex template 1`] = `
<input class=\\"form-check-input\\" type=\\"checkbox\\" name=\\"display_dev\\"/> <input class=\\"form-check-input\\" type=\\"checkbox\\" name=\\"display_dev\\"/>
<label class=\\"form-check-label\\" for=\\"display_dev\\">Display dev</label> <label class=\\"form-check-label\\" for=\\"display_dev\\">Display dev</label>
</div> </div>
</div--><div class=\\"form-group col-md-6\\"><h5>Triggers</h5><block-child-3/></div></div></div><div class=\\"container-fluid frontend\\"><div class=\\"row\\"><div class=\\"col-md-12\\"><block-child-4/></div><div class=\\"col-md-12\\"><block-child-5/><block-child-6/><block-child-7/></div></div></div></div>\`); </div-->
let block3 = createBlock(\`<li class=\\"nav-item\\"><a class=\\"nav-link\\" href=\\"#\\" block-handler-0=\\"click\\"><block-text-1/></a></li>\`); <div class=\\"form-group col-md-6\\">
let block5 = createBlock(\`<li class=\\"nav-item dropdown\\"><b><a class=\\"nav-link\\" block-attribute-0=\\"href\\">Login</a></b></li>\`); <h5>Triggers</h5>
let block8 = createBlock(\`<li class=\\"nav-item\\"><a href=\\"/runbot/errors\\" class=\\"nav-link text-danger\\" block-attribute-0=\\"title\\"><i class=\\"fa fa-bug\\"/><block-text-1/></a></li>\`); <block-child-3/>
let block9 = createBlock(\`<li class=\\"nav-item divider\\"/>\`); </div>
let block11 = createBlock(\`<li class=\\"nav-item\\"><a href=\\"/runbot/errors\\" class=\\"nav-link\\" title=\\"Random Bugs\\"><i class=\\"fa fa-bug\\"/></a></li>\`); </div>
let block12 = createBlock(\`<li class=\\"nav-item divider\\"/>\`); </div>
let block13 = createBlock(\`<li class=\\"nav-item dropdown\\"><a href=\\"#\\" class=\\"nav-link dropdown-toggle\\" data-toggle=\\"dropdown\\"><b><span><block-text-0/></span></b></a><div class=\\"dropdown-menu js_usermenu\\" role=\\"menu\\"><a class=\\"dropdown-item\\" id=\\"o_logout\\" role=\\"menuitem\\" block-attribute-1=\\"href\\">Logout</a><a class=\\"dropdown-item\\" role=\\"menuitem\\" block-attribute-2=\\"href\\">Web</a></div></li>\`);
let block14 = createBlock(\`<select class=\\"custom-select\\" name=\\"category\\" id=\\"category\\"><block-child-0/></select>\`); <div class=\\"container-fluid frontend\\">
let block16 = createBlock(\`<option block-attribute-0=\\"value\\" block-attribute-1=\\"selected\\"><block-text-2/></option>\`); <div class=\\"row\\">
let block20 = createBlock(\`<div class=\\"form-check\\"><input class=\\"form-check-input\\" type=\\"checkbox\\" block-attribute-0=\\"name\\" block-attribute-1=\\"id\\" block-attribute-2=\\"checked\\" block-attribute-3=\\"data-trigger_id\\" block-handler-4=\\"change\\"/><label class=\\"form-check-label\\" block-attribute-5=\\"for\\"><block-text-6/></label></div>\`); <div class=\\"col-md-12\\">
let block21 = createBlock(\`<div><button class=\\"btn btn-sm btn-default\\" block-handler-0=\\"click\\">All</button><button class=\\"btn btn-sm btn-default\\" block-handler-1=\\"click\\">None</button><button class=\\"btn btn-sm btn-info\\" block-handler-2=\\"click\\">Default</button><button class=\\"btn btn-sm btn-default\\" block-handler-3=\\"click\\">Close</button></div>\`); <block-child-4/>
let block23 = createBlock(\`<div class=\\"alert alert-warning\\" role=\\"alert\\"><block-text-0/> <!-- todo fixme--></div>\`); </div>
let block24 = createBlock(\`<div class=\\"mb32\\"><h1>No project</h1></div>\`); <div class=\\"col-md-12\\">
let block25 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); <block-child-5/>
<block-child-6/><block-child-7/>
</div>
</div>
</div>
</div>\`);
let block5 = createBlock(\`<li class=\\"nav-item\\">
<a class=\\"nav-link\\" href=\\"#\\" block-handler-0=\\"click\\">
<block-text-1/>
</a>
</li>\`);
let block10 = createBlock(\`<li class=\\"nav-item dropdown\\">
<b>
<a class=\\"nav-link\\" block-attribute-0=\\"href\\">Login</a>
</b>
</li>\`);
let block16 = createBlock(\`<li class=\\"nav-item\\">
<a href=\\"/runbot/errors\\" class=\\"nav-link text-danger\\" block-attribute-0=\\"title\\">
<i class=\\"fa fa-bug\\"/><block-text-1/>
</a>
</li>\`);
let block18 = createBlock(\`<li class=\\"nav-item divider\\"/>\`);
let block22 = createBlock(\`<li class=\\"nav-item\\">
<a href=\\"/runbot/errors\\" class=\\"nav-link\\" title=\\"Random Bugs\\"><i class=\\"fa fa-bug\\"/></a>
</li>\`);
let block24 = createBlock(\`<li class=\\"nav-item divider\\"/>\`);
let block27 = createBlock(\`<li class=\\"nav-item dropdown\\">
<a href=\\"#\\" class=\\"nav-link dropdown-toggle\\" data-toggle=\\"dropdown\\">
<b>
<span><block-text-0/></span>
</b>
</a>
<div class=\\"dropdown-menu js_usermenu\\" role=\\"menu\\">
<a class=\\"dropdown-item\\" id=\\"o_logout\\" role=\\"menuitem\\" block-attribute-1=\\"href\\">Logout</a>
<a class=\\"dropdown-item\\" role=\\"menuitem\\" block-attribute-2=\\"href\\">Web</a>
</div>
</li>\`);
let block30 = createBlock(\`<select class=\\"custom-select\\" name=\\"category\\" id=\\"category\\">
<block-child-0/>
</select>\`);
let block32 = createBlock(\`<option block-attribute-0=\\"value\\" block-attribute-1=\\"selected\\"><block-text-2/></option>\`);
let block38 = createBlock(\`<div class=\\"form-check\\">
<input class=\\"form-check-input\\" type=\\"checkbox\\" block-attribute-0=\\"name\\" block-attribute-1=\\"id\\" block-attribute-2=\\"checked\\" block-attribute-3=\\"data-trigger_id\\" block-handler-4=\\"change\\"/>
<label class=\\"form-check-label\\" block-attribute-5=\\"for\\"><block-text-6/></label>
</div>\`);
let block41 = createBlock(\`<div>
<button class=\\"btn btn-sm btn-default\\" block-handler-0=\\"click\\">All</button>
<button class=\\"btn btn-sm btn-default\\" block-handler-1=\\"click\\">None</button>
<button class=\\"btn btn-sm btn-info\\" block-handler-2=\\"click\\">Default</button>
<button class=\\"btn btn-sm btn-default\\" block-handler-3=\\"click\\">Close</button>
</div>\`);
let block44 = createBlock(\`<div class=\\"alert alert-warning\\" role=\\"alert\\">
<block-text-0/> <!-- todo fixme-->
</div>\`);
let block45 = createBlock(\`<div class=\\"mb32\\">
<h1>No project</h1>
</div>\`);
let block46 = createBlock(\`<div>
<block-child-0/>
<block-child-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const refs = ctx.__owl__.refs; const refs = ctx.__owl__.refs;
const ref1 = (el) => refs[\`search_input\`] = el; const ref1 = (el) => refs[\`search_input\`] = el;
const ref2 = (el) => refs[\`settings_menu\`] = el; const ref2 = (el) => refs[\`settings_menu\`] = el;
let b2,b4,b14,b17,b22,b23,b24,b25; const b2 = text(\`
\`);
let b4,b6,b30,b33,b43,b44,b45,b46;
let attr1 = \`/runbot/\${ctx['project'].slug}\`; let attr1 = \`/runbot/\${ctx['project'].slug}\`;
let txt1 = ctx['project'].name; let txt1 = ctx['project'].name;
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['projects']);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['projects']);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`project\`] = v_block2[i1]; ctx[\`project\`] = v_block4[i1];
const key1 = ctx['project'].id; const key1 = ctx['project'].id;
let hdlr1 = [ctx['selectProject'](ctx['project']), ctx]; let hdlr1 = [ctx['selectProject'](ctx['project']), ctx];
let txt2 = ctx['project'].name; let txt2 = ctx['project'].name;
c_block2[i1] = withKey(block3([hdlr1, txt2]), key1); c_block4[i1] = withKey(block5([hdlr1, txt2]), key1);
} }
ctx = ctx.__proto__; ctx = ctx.__proto__;
b2 = list(c_block2); b4 = list(c_block4);
if (ctx['user']) { if (ctx['user']) {
let b5,b6; let b7,b8,b12,b29;
b7 = text(\`
\`);
if (ctx['user'].public) { if (ctx['user'].public) {
const b9 = text(\`
\`);
let attr2 = \`/web/login?redirect=/\`; let attr2 = \`/web/login?redirect=/\`;
b5 = block5([attr2]); const b10 = block10([attr2]);
const b11 = text(\`
\`);
b8 = multi([b9, b10, b11]);
} else { } else {
let b7,b10,b13; let b13,b14,b20,b26,b27,b28;
b13 = text(\`
\`);
if (ctx['nb_assigned_errors']&&ctx['nb_assigned_errors']>0) { if (ctx['nb_assigned_errors']&&ctx['nb_assigned_errors']>0) {
const b15 = text(\`
\`);
let attr3 = \`You have \${ctx['nb_assigned_errors']} random bug assigned\`; let attr3 = \`You have \${ctx['nb_assigned_errors']} random bug assigned\`;
let txt3 = ctx['nb_assigned_errors']; let txt3 = ctx['nb_assigned_errors'];
const b8 = block8([attr3, txt3]); const b16 = block16([attr3, txt3]);
const b9 = block9(); const b17 = text(\`
b7 = multi([b8, b9]); \`);
const b18 = block18();
const b19 = text(\`
\`);
b14 = multi([b15, b16, b17, b18, b19]);
} else if (ctx['nb_build_errors']&&ctx['nb_build_errors']>0) { } else if (ctx['nb_build_errors']&&ctx['nb_build_errors']>0) {
const b11 = block11(); const b21 = text(\`
const b12 = block12(); \`);
b10 = multi([b11, b12]); const b22 = block22();
const b23 = text(\`
\`);
const b24 = block24();
const b25 = text(\`
\`);
b20 = multi([b21, b22, b23, b24, b25]);
} }
b26 = text(\`
\`);
let txt4 = ctx['user'].name.length>25?ctx['user'].namesubstring(0,23)+'...':ctx['user'].name; let txt4 = ctx['user'].name.length>25?ctx['user'].namesubstring(0,23)+'...':ctx['user'].name;
let attr4 = \`/web/session/logout?redirect=/\`; let attr4 = \`/web/session/logout?redirect=/\`;
let attr5 = \`/web\`; let attr5 = \`/web\`;
b13 = block13([txt4, attr4, attr5]); b27 = block27([txt4, attr4, attr5]);
b6 = multi([b7, b10, b13]); b28 = text(\`
\`);
b12 = multi([b13, b14, b20, b26, b27, b28]);
} }
b4 = multi([b5, b6]); b29 = text(\`
\`);
b6 = multi([b7, b8, b12, b29]);
} }
let hdlr2 = [ctx['toggleSettingsMenu'], ctx]; let hdlr2 = [ctx['toggleSettingsMenu'], ctx];
let hdlr3 = [ctx['toggleMore'], ctx]; let hdlr3 = [ctx['toggleMore'], ctx];
if (ctx['categories']&&ctx['categories'].length>1) { if (ctx['categories']&&ctx['categories'].length>1) {
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block15, v_block15, l_block15, c_block15] = prepareList(ctx['categories']);; const [k_block31, v_block31, l_block31, c_block31] = prepareList(ctx['categories']);;
for (let i1 = 0; i1 < l_block15; i1++) { for (let i1 = 0; i1 < l_block31; i1++) {
ctx[\`category\`] = v_block15[i1]; ctx[\`category\`] = v_block31[i1];
const key1 = ctx['category'].id; const key1 = ctx['category'].id;
let attr6 = ctx['category'].id; let attr6 = ctx['category'].id;
let attr7 = ctx['category'].id==ctx['options'].active_category_id; let attr7 = ctx['category'].id==ctx['options'].active_category_id;
let txt5 = ctx['category'].name; let txt5 = ctx['category'].name;
c_block15[i1] = withKey(block16([attr6, attr7, txt5]), key1); c_block31[i1] = withKey(block32([attr6, attr7, txt5]), key1);
} }
ctx = ctx.__proto__; ctx = ctx.__proto__;
const b15 = list(c_block15); const b31 = list(c_block31);
b14 = block14([], [b15]); b30 = block30([], [b31]);
} }
let attr8 = ctx['search'].value; let attr8 = ctx['search'].value;
let hdlr4 = [ctx['updateFilter'], ctx]; let hdlr4 = [ctx['updateFilter'], ctx];
let hdlr5 = [ctx['updateFilter'], ctx]; let hdlr5 = [ctx['updateFilter'], ctx];
let hdlr6 = [ctx['clearSearch'], ctx]; let hdlr6 = [ctx['clearSearch'], ctx];
if (ctx['triggers']) { if (ctx['triggers']) {
const b34 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block18, v_block18, l_block18, c_block18] = prepareList(ctx['triggers']);; const [k_block35, v_block35, l_block35, c_block35] = prepareList(ctx['triggers']);;
for (let i1 = 0; i1 < l_block18; i1++) { for (let i1 = 0; i1 < l_block35; i1++) {
ctx[\`trigger\`] = v_block18[i1]; ctx[\`trigger\`] = v_block35[i1];
const key1 = ctx['trigger'].id; const key1 = ctx['trigger'].id;
let b20; let b37,b38,b39;
b37 = text(\`
\`);
if (!ctx['trigger'].manual&&ctx['trigger'].project_id===ctx['project'].id&&ctx['trigger'].category_id===ctx['options'].active_category_id) { if (!ctx['trigger'].manual&&ctx['trigger'].project_id===ctx['project'].id&&ctx['trigger'].category_id===ctx['options'].active_category_id) {
let attr9 = \`trigger_\${ctx['trigger'].id}\`; let attr9 = \`trigger_\${ctx['trigger'].id}\`;
let attr10 = \`trigger_\${ctx['trigger'].id}\`; let attr10 = \`trigger_\${ctx['trigger'].id}\`;
@@ -296,34 +500,41 @@ exports[`misc other complex template 1`] = `
let hdlr7 = [ctx['updateTriggerDisplay'], ctx]; let hdlr7 = [ctx['updateTriggerDisplay'], ctx];
let attr13 = \`trigger_\${ctx['trigger'].id}\`; let attr13 = \`trigger_\${ctx['trigger'].id}\`;
let txt6 = ctx['trigger'].name; let txt6 = ctx['trigger'].name;
b20 = block20([attr9, attr10, attr11, attr12, hdlr7, attr13, txt6]); b38 = block38([attr9, attr10, attr11, attr12, hdlr7, attr13, txt6]);
} }
c_block18[i1] = withKey(multi([b20]), key1); b39 = text(\`
\`);
c_block35[i1] = withKey(multi([b37, b38, b39]), key1);
} }
ctx = ctx.__proto__; ctx = ctx.__proto__;
const b18 = list(c_block18); const b35 = list(c_block35);
const b40 = text(\`
\`);
let hdlr8 = [ctx['triggerAll'], ctx]; let hdlr8 = [ctx['triggerAll'], ctx];
let hdlr9 = [ctx['triggerNone'], ctx]; let hdlr9 = [ctx['triggerNone'], ctx];
let hdlr10 = [ctx['triggerDefault'], ctx]; let hdlr10 = [ctx['triggerDefault'], ctx];
let hdlr11 = [ctx['toggleSettingsMenu'], ctx]; let hdlr11 = [ctx['toggleSettingsMenu'], ctx];
const b21 = block21([hdlr8, hdlr9, hdlr10, hdlr11]); const b41 = block41([hdlr8, hdlr9, hdlr10, hdlr11]);
b17 = multi([b18, b21]); const b42 = text(\`
\`);
b33 = multi([b34, b35, b40, b41, b42]);
} }
if (ctx['load_infos']) { if (ctx['load_infos']) {
b22 = callTemplate_1.call(this, ctx, node, key + \`__1\`); b43 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
} }
if (ctx['message']) { if (ctx['message']) {
let txt7 = ctx['message']; let txt7 = ctx['message'];
b23 = block23([txt7]); b44 = block44([txt7]);
} }
if (!ctx['project']) { if (!ctx['project']) {
b24 = block24(); b45 = block45();
} else { } else {
const b26 = comp1({bundles: ctx['bundles'].sticky,category_custom_views: ctx['category_custom_views'],search: ctx['search']}, key + \`__2\`, node, ctx, null); const b47 = comp1({bundles: ctx['bundles'].sticky,category_custom_views: ctx['category_custom_views'],search: ctx['search']}, key + \`__2\`, node, this, null);
const b27 = comp2({bundles: ctx['bundles'].dev,search: ctx['search']}, key + \`__3\`, node, ctx, null); const b48 = comp2({bundles: ctx['bundles'].dev,search: ctx['search']}, key + \`__3\`, node, this, null);
b25 = block25([], [b26, b27]); b46 = block46([], [b47, b48]);
} }
return block1([attr1, txt1, hdlr2, hdlr3, attr8, hdlr4, hdlr5, ref1, hdlr6, ref2], [b2, b4, b14, b17, b22, b23, b24, b25]); const b3 = block3([attr1, txt1, hdlr2, hdlr3, attr8, hdlr4, hdlr5, ref1, hdlr6, ref2], [b4, b6, b30, b33, b43, b44, b45, b46]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -313,13 +313,22 @@ exports[`simple templates, mostly static template with multiple t tag with multi
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><block-text-0/><block-text-1/>Loading<block-text-2/></div>\`); let block3 = createBlock(\`<div>
<block-text-0/>
<block-text-1/>
Loading<block-text-2/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let txt1 = ctx['a']; let txt1 = ctx['a'];
let txt2 = ctx['b']; let txt2 = ctx['b'];
let txt3 = ctx['c']; let txt3 = ctx['c'];
return block1([txt1, txt2, txt3]); const b3 = block3([txt1, txt2, txt3]);
return multi([b2, b3]);
} }
}" }"
`; `;
+30 -11
View File
@@ -57,17 +57,27 @@ exports[`properly support svg svg creates new block if it is within html -- 2 1`
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block2 = createBlock(\`<svg block-ns=\\"http://www.w3.org/2000/svg\\"><polygon fill=\\"#000000\\" points=\\"0 0 4 4 8 0\\" transform=\\"translate(5 7)\\"/><block-child-0/></svg>\`); <block-child-0/>
let block3 = createBlock(\`<path block-ns=\\"http://www.w3.org/2000/svg\\"/>\`); </div>\`);
let block4 = createBlock(\`<svg block-ns=\\"http://www.w3.org/2000/svg\\">
<polygon fill=\\"#000000\\" points=\\"0 0 4 4 8 0\\" transform=\\"translate(5 7)\\"/>
<block-child-0/>
</svg>\`);
let block5 = createBlock(\`<path block-ns=\\"http://www.w3.org/2000/svg\\"/>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b3; const b2 = text(\`
\`);
let b5;
if (ctx['hasPath']) { if (ctx['hasPath']) {
b3 = block3(); b5 = block5();
} }
const b2 = block2([], [b3]); const b4 = block4([], [b5]);
return block1([], [b2]); const b3 = block3([], [b4]);
const b6 = text(\`
\`);
return multi([b2, b3, b6]);
} }
}" }"
`; `;
@@ -77,12 +87,21 @@ exports[`properly support svg svg creates new block if it is within html 1`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block2 = createBlock(\`<svg block-ns=\\"http://www.w3.org/2000/svg\\"><polygon fill=\\"#000000\\" points=\\"0 0 4 4 8 0\\" transform=\\"translate(5 7)\\"/></svg>\`); <block-child-0/>
</div>\`);
let block4 = createBlock(\`<svg block-ns=\\"http://www.w3.org/2000/svg\\">
<polygon fill=\\"#000000\\" points=\\"0 0 4 4 8 0\\" transform=\\"translate(5 7)\\"/>
</svg>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = block2(); const b2 = text(\`
return block1([], [b2]); \`);
const b4 = block4();
const b3 = block3([], [b4]);
const b5 = text(\`
\`);
return multi([b2, b3, b5]);
} }
}" }"
`; `;
File diff suppressed because it is too large Load Diff
@@ -55,7 +55,10 @@ exports[`debugging t-log 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue } = helpers; let { isBoundary, withDefault, setContextValue } = helpers;
let block1 = createBlock(\`<div/>\`); let block1 = createBlock(\`<div>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
+60 -13
View File
@@ -5,15 +5,24 @@ exports[`t-esc div with falsy values 1`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><p><block-text-0/></p><p><block-text-1/></p><p><block-text-2/></p><p><block-text-3/></p><p><block-text-4/></p></div>\`); let block3 = createBlock(\`<div>
<p><block-text-0/></p>
<p><block-text-1/></p>
<p><block-text-2/></p>
<p><block-text-3/></p>
<p><block-text-4/></p>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let txt1 = ctx['v1']; let txt1 = ctx['v1'];
let txt2 = ctx['v2']; let txt2 = ctx['v2'];
let txt3 = ctx['v3']; let txt3 = ctx['v3'];
let txt4 = ctx['v4']; let txt4 = ctx['v4'];
let txt5 = ctx['v5']; let txt5 = ctx['v5'];
return block1([txt1, txt2, txt3, txt4, txt5]); const b3 = block3([txt1, txt2, txt3, txt4, txt5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -82,16 +91,18 @@ exports[`t-esc falsy values in text nodes 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(ctx['v1']); const b2 = text(\`
const b3 = text(\`:\`); \`);
const b4 = text(ctx['v2']); const b3 = text(ctx['v1']);
const b5 = text(\`:\`); const b4 = text(\`:\`);
const b6 = text(ctx['v3']); const b5 = text(ctx['v2']);
const b7 = text(\`:\`); const b6 = text(\`:\`);
const b8 = text(ctx['v4']); const b7 = text(ctx['v3']);
const b9 = text(\`:\`); const b8 = text(\`:\`);
const b10 = text(ctx['v5']); const b9 = text(ctx['v4']);
return multi([b2, b3, b4, b5, b6, b7, b8, b9, b10]); const b10 = text(\`:\`);
const b11 = text(ctx['v5']);
return multi([b2, b3, b4, b5, b6, b7, b8, b9, b10, b11]);
} }
}" }"
`; `;
@@ -126,7 +137,32 @@ exports[`t-esc t-esc is escaped 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
ctx[\`var\`] = new LazyValue(value1, ctx, node); ctx[\`var\`] = new LazyValue(value1, ctx, this, node);
let txt1 = ctx['var'];
return block1([txt1]);
}
}"
`;
exports[`t-esc t-esc with the 0 number 1`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
return function template(ctx, node, key = \\"\\") {
return text(ctx['var']);
}
}"
`;
exports[`t-esc t-esc with the 0 number, in a p 1`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<p><block-text-0/></p>\`);
return function template(ctx, node, key = \\"\\") {
let txt1 = ctx['var']; let txt1 = ctx['var'];
return block1([txt1]); return block1([txt1]);
} }
@@ -183,6 +219,17 @@ exports[`t-esc t-esc=0 is escaped 2`] = `
}" }"
`; `;
exports[`t-esc top level t-esc with undefined 1`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
return function template(ctx, node, key = \\"\\") {
return text(ctx['var']);
}
}"
`;
exports[`t-esc variable 1`] = ` exports[`t-esc variable 1`] = `
"function anonymous(app, bdom, helpers "function anonymous(app, bdom, helpers
) { ) {
@@ -6,18 +6,24 @@ exports[`t-foreach does not pollute the rendering context 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList([1]);; const [k_block4, v_block4, l_block4, c_block4] = prepareList([1]);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`item\`] = v_block2[i1]; ctx[\`item\`] = v_block4[i1];
const key1 = ctx['item']; const key1 = ctx['item'];
c_block2[i1] = withKey(text(ctx['item']), key1); c_block4[i1] = withKey(text(ctx['item']), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -28,20 +34,26 @@ exports[`t-foreach iterate on items (on a element node) 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block3 = createBlock(\`<span><block-text-0/></span>\`); <block-child-0/>
</div>\`);
let block5 = createBlock(\`<span><block-text-0/></span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList([1,2]);; const [k_block4, v_block4, l_block4, c_block4] = prepareList([1,2]);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`item\`] = v_block2[i1]; ctx[\`item\`] = v_block4[i1];
const key1 = ctx['item']; const key1 = ctx['item'];
let txt1 = ctx['item']; let txt1 = ctx['item'];
c_block2[i1] = withKey(block3([txt1]), key1); c_block4[i1] = withKey(block5([txt1]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -52,27 +64,35 @@ exports[`t-foreach iterate on items 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList([3,2,1]);; const [k_block4, v_block4, l_block4, c_block4] = prepareList([3,2,1]);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`item\`] = v_block2[i1]; ctx[\`item\`] = v_block4[i1];
ctx[\`item_index\`] = i1; ctx[\`item_index\`] = i1;
ctx[\`item_value\`] = k_block2[i1]; ctx[\`item_value\`] = k_block4[i1];
const key1 = ctx['item']; const key1 = ctx['item'];
const b4 = text(\` [\`); const b6 = text(\`
const b5 = text(ctx['item_index']); [\`);
const b6 = text(\`: \`); const b7 = text(ctx['item_index']);
const b7 = text(ctx['item']); const b8 = text(\`: \`);
const b8 = text(\` \`); const b9 = text(ctx['item']);
const b9 = text(ctx['item_value']); const b10 = text(\` \`);
const b10 = text(\`] \`); const b11 = text(ctx['item_value']);
c_block2[i1] = withKey(multi([b4, b5, b6, b7, b8, b9, b10]), key1); const b12 = text(\`]
\`);
c_block4[i1] = withKey(multi([b6, b7, b8, b9, b10, b11, b12]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -83,27 +103,35 @@ exports[`t-foreach iterate, dict param 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['value']);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['value']);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`item\`] = v_block2[i1]; ctx[\`item\`] = v_block4[i1];
ctx[\`item_index\`] = i1; ctx[\`item_index\`] = i1;
ctx[\`item_value\`] = k_block2[i1]; ctx[\`item_value\`] = k_block4[i1];
const key1 = ctx['item_index']; const key1 = ctx['item_index'];
const b4 = text(\` [\`); const b6 = text(\`
const b5 = text(ctx['item_index']); [\`);
const b6 = text(\`: \`); const b7 = text(ctx['item_index']);
const b7 = text(ctx['item']); const b8 = text(\`: \`);
const b8 = text(\` \`); const b9 = text(ctx['item']);
const b9 = text(ctx['item_value']); const b10 = text(\` \`);
const b10 = text(\`] \`); const b11 = text(ctx['item_value']);
c_block2[i1] = withKey(multi([b4, b5, b6, b7, b8, b9, b10]), key1); const b12 = text(\`]
\`);
c_block4[i1] = withKey(multi([b6, b7, b8, b9, b10, b11, b12]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -114,32 +142,40 @@ exports[`t-foreach iterate, position 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(Array(5));; const [k_block4, v_block4, l_block4, c_block4] = prepareList(Array(5));;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`elem\`] = v_block2[i1]; ctx[\`elem\`] = v_block4[i1];
ctx[\`elem_first\`] = i1 === 0; ctx[\`elem_first\`] = i1 === 0;
ctx[\`elem_last\`] = i1 === v_block2.length - 1; ctx[\`elem_last\`] = i1 === v_block4.length - 1;
ctx[\`elem_index\`] = i1; ctx[\`elem_index\`] = i1;
const key1 = ctx['elem']; const key1 = ctx['elem'];
let b4,b5,b6,b7,b8,b9; let b6,b7,b8,b9,b10,b11;
b4 = text(\` -\`); b6 = text(\`
-\`);
if (ctx['elem_first']) { if (ctx['elem_first']) {
b5 = text(\` first\`); b7 = text(\` first\`);
} }
if (ctx['elem_last']) { if (ctx['elem_last']) {
b6 = text(\` last\`); b8 = text(\` last\`);
} }
b7 = text(\` (\`); b9 = text(\` (\`);
b8 = text(ctx['elem_index']); b10 = text(ctx['elem_index']);
b9 = text(\`) \`); b11 = text(\`)
c_block2[i1] = withKey(multi([b4, b5, b6, b7, b8, b9]), key1); \`);
c_block4[i1] = withKey(multi([b6, b7, b8, b9, b10, b11]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -150,18 +186,24 @@ exports[`t-foreach simple iteration (in a node) 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList([3,2,1]);; const [k_block4, v_block4, l_block4, c_block4] = prepareList([3,2,1]);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`item\`] = v_block2[i1]; ctx[\`item\`] = v_block4[i1];
const key1 = ctx['item']; const key1 = ctx['item'];
c_block2[i1] = withKey(text(ctx['item']), key1); c_block4[i1] = withKey(text(ctx['item']), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -191,22 +233,31 @@ exports[`t-foreach simple iteration with two nodes inside 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
let block3 = createBlock(\`<span>a<block-text-0/></span>\`); let block6 = createBlock(\`<span>a<block-text-0/></span>\`);
let block4 = createBlock(\`<span>b<block-text-0/></span>\`); let block8 = createBlock(\`<span>b<block-text-0/></span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block1, v_block1, l_block1, c_block1] = prepareList([3,2,1]);; const [k_block3, v_block3, l_block3, c_block3] = prepareList([3,2,1]);;
for (let i1 = 0; i1 < l_block1; i1++) { for (let i1 = 0; i1 < l_block3; i1++) {
ctx[\`item\`] = v_block1[i1]; ctx[\`item\`] = v_block3[i1];
const key1 = ctx['item']; const key1 = ctx['item'];
const b5 = text(\`
\`);
let txt1 = ctx['item']; let txt1 = ctx['item'];
const b3 = block3([txt1]); const b6 = block6([txt1]);
const b7 = text(\`
\`);
let txt2 = ctx['item']; let txt2 = ctx['item'];
const b4 = block4([txt2]); const b8 = block8([txt2]);
c_block1[i1] = withKey(multi([b3, b4]), key1); const b9 = text(\`
\`);
c_block3[i1] = withKey(multi([b5, b6, b7, b8, b9]), key1);
} }
return list(c_block1); const b3 = list(c_block3);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -215,51 +266,74 @@ exports[`t-foreach t-call with body in t-foreach in t-foreach 1`] = `
"function anonymous(app, bdom, helpers "function anonymous(app, bdom, helpers
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, isBoundary, withDefault, setContextValue, withKey } = helpers; let { prepareList, isBoundary, withDefault, setContextValue, zero, withKey } = helpers;
const callTemplate_1 = app.getTemplate(\`sub\`); const callTemplate_1 = app.getTemplate(\`sub\`);
let block1 = createBlock(\`<div><block-child-0/><span>[<block-text-0/>][<block-text-1/>][<block-text-2/>]</span></div>\`); let block3 = createBlock(\`<div>
let block6 = createBlock(\`<span><block-text-0/></span>\`); <block-child-0/>
<span>[<block-text-0/>][<block-text-1/>][<block-text-2/>]</span>
</div>\`);
let block16 = createBlock(\`<span><block-text-0/></span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['numbers']);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['numbers']);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`a\`] = v_block2[i1]; ctx[\`a\`] = v_block4[i1];
ctx[\`a_first\`] = i1 === 0; ctx[\`a_first\`] = i1 === 0;
ctx[\`a_last\`] = i1 === v_block2.length - 1; ctx[\`a_last\`] = i1 === v_block4.length - 1;
ctx[\`a_index\`] = i1; ctx[\`a_index\`] = i1;
ctx[\`a_value\`] = k_block2[i1]; ctx[\`a_value\`] = k_block4[i1];
const key1 = ctx['a']; const key1 = ctx['a'];
const b6 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['letters']);; const [k_block7, v_block7, l_block7, c_block7] = prepareList(ctx['letters']);;
for (let i2 = 0; i2 < l_block4; i2++) { for (let i2 = 0; i2 < l_block7; i2++) {
ctx[\`b\`] = v_block4[i2]; ctx[\`b\`] = v_block7[i2];
ctx[\`b_first\`] = i2 === 0; ctx[\`b_first\`] = i2 === 0;
ctx[\`b_last\`] = i2 === v_block4.length - 1; ctx[\`b_last\`] = i2 === v_block7.length - 1;
ctx[\`b_index\`] = i2; ctx[\`b_index\`] = i2;
ctx[\`b_value\`] = k_block4[i2]; ctx[\`b_value\`] = k_block7[i2];
const key2 = ctx['b']; const key2 = ctx['b'];
const b9 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1; ctx[isBoundary] = 1;
const b11 = text(\`
\`);
setContextValue(ctx, \\"c\\", 'x'+'_'+ctx['a']+'_'+ctx['b']); setContextValue(ctx, \\"c\\", 'x'+'_'+ctx['a']+'_'+ctx['b']);
c_block4[i2] = withKey(callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}__\${key2}\`), key2); const b12 = text(\`
\`);
const b10 = multi([b11, b12]);
ctx[zero] = b10;
const b13 = callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}__\${key2}\`);
ctx = ctx.__proto__; ctx = ctx.__proto__;
const b14 = text(\`
\`);
c_block7[i2] = withKey(multi([b9, b13, b14]), key2);
} }
ctx = ctx.__proto__; ctx = ctx.__proto__;
const b4 = list(c_block4); const b7 = list(c_block7);
const b15 = text(\`
\`);
let txt1 = ctx['c']; let txt1 = ctx['c'];
const b6 = block6([txt1]); const b16 = block16([txt1]);
c_block2[i1] = withKey(multi([b4, b6]), key1); const b17 = text(\`
\`);
c_block4[i1] = withKey(multi([b6, b7, b15, b16, b17]), key1);
} }
ctx = ctx.__proto__; ctx = ctx.__proto__;
const b2 = list(c_block2); const b4 = list(c_block4);
let txt2 = ctx['a']; let txt2 = ctx['a'];
let txt3 = ctx['b']; let txt3 = ctx['b'];
let txt4 = ctx['c']; let txt4 = ctx['c'];
return block1([txt2, txt3, txt4], [b2]); const b3 = block3([txt2, txt3, txt4], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -270,14 +344,20 @@ exports[`t-foreach t-call with body in t-foreach in t-foreach 2`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\` [\`); const b2 = text(\`
const b3 = text(ctx['a']); \`);
const b4 = text(\`] [\`); const b3 = text(\`
const b5 = text(ctx['b']); [\`);
const b6 = text(\`] [\`); const b4 = text(ctx['a']);
const b7 = text(ctx['c']); const b5 = text(\`]
const b8 = text(\`] \`); [\`);
return multi([b2, b3, b4, b5, b6, b7, b8]); const b6 = text(ctx['b']);
const b7 = text(\`]
[\`);
const b8 = text(ctx['c']);
const b9 = text(\`]
\`);
return multi([b2, b3, b4, b5, b6, b7, b8, b9]);
} }
}" }"
`; `;
@@ -289,42 +369,59 @@ exports[`t-foreach t-call without body in t-foreach in t-foreach 1`] = `
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
const callTemplate_1 = app.getTemplate(\`sub\`); const callTemplate_1 = app.getTemplate(\`sub\`);
let block1 = createBlock(\`<div><block-child-0/><span>[<block-text-0/>][<block-text-1/>][<block-text-2/>]</span></div>\`); let block3 = createBlock(\`<div>
let block6 = createBlock(\`<span><block-text-0/></span>\`); <block-child-0/>
<span>[<block-text-0/>][<block-text-1/>][<block-text-2/>]</span>
</div>\`);
let block13 = createBlock(\`<span><block-text-0/></span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['numbers']);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['numbers']);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`a\`] = v_block2[i1]; ctx[\`a\`] = v_block4[i1];
ctx[\`a_first\`] = i1 === 0; ctx[\`a_first\`] = i1 === 0;
ctx[\`a_last\`] = i1 === v_block2.length - 1; ctx[\`a_last\`] = i1 === v_block4.length - 1;
ctx[\`a_index\`] = i1; ctx[\`a_index\`] = i1;
ctx[\`a_value\`] = k_block2[i1]; ctx[\`a_value\`] = k_block4[i1];
const key1 = ctx['a']; const key1 = ctx['a'];
const b6 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['letters']);; const [k_block7, v_block7, l_block7, c_block7] = prepareList(ctx['letters']);;
for (let i2 = 0; i2 < l_block4; i2++) { for (let i2 = 0; i2 < l_block7; i2++) {
ctx[\`b\`] = v_block4[i2]; ctx[\`b\`] = v_block7[i2];
ctx[\`b_first\`] = i2 === 0; ctx[\`b_first\`] = i2 === 0;
ctx[\`b_last\`] = i2 === v_block4.length - 1; ctx[\`b_last\`] = i2 === v_block7.length - 1;
ctx[\`b_index\`] = i2; ctx[\`b_index\`] = i2;
ctx[\`b_value\`] = k_block4[i2]; ctx[\`b_value\`] = k_block7[i2];
const key2 = ctx['b']; const key2 = ctx['b'];
c_block4[i2] = withKey(callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}__\${key2}\`), key2); const b9 = text(\`
\`);
const b10 = callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}__\${key2}\`);
const b11 = text(\`
\`);
c_block7[i2] = withKey(multi([b9, b10, b11]), key2);
} }
ctx = ctx.__proto__; ctx = ctx.__proto__;
const b4 = list(c_block4); const b7 = list(c_block7);
const b12 = text(\`
\`);
let txt1 = ctx['c']; let txt1 = ctx['c'];
const b6 = block6([txt1]); const b13 = block13([txt1]);
c_block2[i1] = withKey(multi([b4, b6]), key1); const b14 = text(\`
\`);
c_block4[i1] = withKey(multi([b6, b7, b12, b13, b14]), key1);
} }
ctx = ctx.__proto__; ctx = ctx.__proto__;
const b2 = list(c_block2); const b4 = list(c_block4);
let txt2 = ctx['a']; let txt2 = ctx['a'];
let txt3 = ctx['b']; let txt3 = ctx['b'];
let txt4 = ctx['c']; let txt4 = ctx['c'];
return block1([txt2, txt3, txt4], [b2]); const b3 = block3([txt2, txt3, txt4], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -338,15 +435,23 @@ exports[`t-foreach t-call without body in t-foreach in t-foreach 2`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
const b3 = text(\`
\`);
setContextValue(ctx, \\"c\\", 'x'+'_'+ctx['a']+'_'+ctx['b']); setContextValue(ctx, \\"c\\", 'x'+'_'+ctx['a']+'_'+ctx['b']);
const b2 = text(\` [\`); const b4 = text(\`
const b3 = text(ctx['a']); [\`);
const b4 = text(\`] [\`); const b5 = text(ctx['a']);
const b5 = text(ctx['b']); const b6 = text(\`]
const b6 = text(\`] [\`); [\`);
const b7 = text(ctx['c']); const b7 = text(ctx['b']);
const b8 = text(\`] \`); const b8 = text(\`]
return multi([b2, b3, b4, b5, b6, b7, b8]); [\`);
const b9 = text(ctx['c']);
const b10 = text(\`]
\`);
return multi([b2, b3, b4, b5, b6, b7, b8, b9, b10]);
} }
}" }"
`; `;
@@ -357,30 +462,43 @@ exports[`t-foreach t-foreach in t-foreach 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['numbers']);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['numbers']);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`number\`] = v_block2[i1]; ctx[\`number\`] = v_block4[i1];
const key1 = ctx['number']; const key1 = ctx['number'];
const b6 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block3, v_block3, l_block3, c_block3] = prepareList(ctx['letters']);; const [k_block7, v_block7, l_block7, c_block7] = prepareList(ctx['letters']);;
for (let i2 = 0; i2 < l_block3; i2++) { for (let i2 = 0; i2 < l_block7; i2++) {
ctx[\`letter\`] = v_block3[i2]; ctx[\`letter\`] = v_block7[i2];
const key2 = ctx['letter']; const key2 = ctx['letter'];
const b5 = text(\` [\`); const b9 = text(\`
const b6 = text(ctx['number']); [\`);
const b7 = text(ctx['letter']); const b10 = text(ctx['number']);
const b8 = text(\`] \`); const b11 = text(ctx['letter']);
c_block3[i2] = withKey(multi([b5, b6, b7, b8]), key2); const b12 = text(\`]
\`);
c_block7[i2] = withKey(multi([b9, b10, b11, b12]), key2);
} }
ctx = ctx.__proto__; ctx = ctx.__proto__;
c_block2[i1] = withKey(list(c_block3), key1); const b7 = list(c_block7);
const b13 = text(\`
\`);
c_block4[i1] = withKey(multi([b6, b7, b13]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -391,22 +509,29 @@ exports[`t-foreach t-foreach with t-if inside (no external node) 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
let block3 = createBlock(\`<span><block-text-0/></span>\`); let block6 = createBlock(\`<span><block-text-0/></span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block1, v_block1, l_block1, c_block1] = prepareList(ctx['elems']);; const [k_block3, v_block3, l_block3, c_block3] = prepareList(ctx['elems']);;
for (let i1 = 0; i1 < l_block1; i1++) { for (let i1 = 0; i1 < l_block3; i1++) {
ctx[\`elem\`] = v_block1[i1]; ctx[\`elem\`] = v_block3[i1];
const key1 = ctx['elem'].id; const key1 = ctx['elem'].id;
let b3; let b5,b6,b7;
b5 = text(\`
\`);
if (ctx['elem'].id<3) { if (ctx['elem'].id<3) {
let txt1 = ctx['elem'].text; let txt1 = ctx['elem'].text;
b3 = block3([txt1]); b6 = block6([txt1]);
} }
c_block1[i1] = withKey(multi([b3]), key1); b7 = text(\`
\`);
c_block3[i1] = withKey(multi([b5, b6, b7]), key1);
} }
return list(c_block1); const b3 = list(c_block3);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -417,24 +542,34 @@ exports[`t-foreach t-foreach with t-if inside 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block4 = createBlock(\`<span><block-text-0/></span>\`); <block-child-0/>
</div>\`);
let block7 = createBlock(\`<span><block-text-0/></span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['elems']);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['elems']);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`elem\`] = v_block2[i1]; ctx[\`elem\`] = v_block4[i1];
const key1 = ctx['elem'].id; const key1 = ctx['elem'].id;
let b4; let b6,b7,b8;
b6 = text(\`
\`);
if (ctx['elem'].id<3) { if (ctx['elem'].id<3) {
let txt1 = ctx['elem'].text; let txt1 = ctx['elem'].text;
b4 = block4([txt1]); b7 = block7([txt1]);
} }
c_block2[i1] = withKey(multi([b4]), key1); b8 = text(\`
\`);
c_block4[i1] = withKey(multi([b6, b7, b8]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -445,19 +580,30 @@ exports[`t-foreach t-key on t-foreach 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block3 = createBlock(\`<span/>\`); <block-child-0/>
</div>\`);
let block7 = createBlock(\`<span/>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['things']);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['things']);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`thing\`] = v_block2[i1]; ctx[\`thing\`] = v_block4[i1];
const key1 = ctx['thing']; const key1 = ctx['thing'];
c_block2[i1] = withKey(block3(), key1); const b6 = text(\`
\`);
const b7 = block7();
const b8 = text(\`
\`);
c_block4[i1] = withKey(multi([b6, b7, b8]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -493,33 +639,42 @@ exports[`t-foreach with t-memo 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block3 = createBlock(\`<p><block-text-0/><block-text-1/></p>\`); <block-child-0/>
</div>\`);
let block5 = createBlock(\`<p>
<block-text-0/>
<block-text-1/>
</p>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let cache = ctx.cache || {}; let cache = ctx.cache || {};
let nextCache = ctx.cache = {}; let nextCache = ctx.cache = {};
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['items']);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['items']);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`item\`] = v_block2[i1]; ctx[\`item\`] = v_block4[i1];
const key1 = ctx['item'].id; const key1 = ctx['item'].id;
const memo1 = [ctx['item'].x]; const memo1 = [ctx['item'].x];
const vnode1 = cache[key1];; const vnode1 = cache[key1];;
if (vnode1) { if (vnode1) {
if (shallowEqual(vnode1.memo, memo1)) { if (shallowEqual(vnode1.memo, memo1)) {
c_block2[i1] = vnode1; c_block4[i1] = vnode1;
nextCache[key1] = vnode1; nextCache[key1] = vnode1;
continue; continue;
} }
} }
let txt1 = ctx['item'].x; let txt1 = ctx['item'].x;
let txt2 = ctx['item'].y; let txt2 = ctx['item'].y;
c_block2[i1] = withKey(block3([txt1, txt2]), key1); c_block4[i1] = withKey(block5([txt1, txt2]), key1);
nextCache[key1] = Object.assign(c_block2[i1], {memo: memo1}); nextCache[key1] = Object.assign(c_block4[i1], {memo: memo1});
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
+102 -53
View File
@@ -44,17 +44,19 @@ exports[`t-if boolean value condition elif (no outside node) 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3,b4,b5; let b2,b3,b4,b5,b6;
b2 = text(\`
\`);
if (ctx['color']=='black') { if (ctx['color']=='black') {
b2 = text(\`black pearl\`); b3 = text(\`black pearl\`);
} else if (ctx['color']=='yellow') { } else if (ctx['color']=='yellow') {
b3 = text(\`yellow submarine\`); b4 = text(\`yellow submarine\`);
} else if (ctx['color']=='red') { } else if (ctx['color']=='red') {
b4 = text(\`red is dead\`); b5 = text(\`red is dead\`);
} else { } else {
b5 = text(\`beer\`); b6 = text(\`beer\`);
} }
return multi([b2, b3, b4, b5]); return multi([b2, b3, b4, b5, b6]);
} }
}" }"
`; `;
@@ -64,20 +66,25 @@ exports[`t-if boolean value condition elif 1`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-2/><block-child-3/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/><block-child-1/><block-child-2/><block-child-3/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3,b4,b5; const b2 = text(\`
\`);
let b4,b5,b6,b7;
if (ctx['color']=='black') { if (ctx['color']=='black') {
b2 = text(\`black pearl\`); b4 = text(\`black pearl\`);
} else if (ctx['color']=='yellow') { } else if (ctx['color']=='yellow') {
b3 = text(\`yellow submarine\`); b5 = text(\`yellow submarine\`);
} else if (ctx['color']=='red') { } else if (ctx['color']=='red') {
b4 = text(\`red is dead\`); b6 = text(\`red is dead\`);
} else { } else {
b5 = text(\`beer\`); b7 = text(\`beer\`);
} }
return block1([], [b2, b3, b4, b5]); const b3 = block3([], [b4, b5, b6, b7]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -87,16 +94,23 @@ exports[`t-if boolean value condition else 1`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><span>begin</span><block-child-0/><block-child-1/><span>end</span></div>\`); let block3 = createBlock(\`<div>
<span>begin</span>
<block-child-0/><block-child-1/>
<span>end</span>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; const b2 = text(\`
\`);
let b4,b5;
if (ctx['condition']) { if (ctx['condition']) {
b2 = text(\`ok\`); b4 = text(\`ok\`);
} else { } else {
b3 = text(\`ok-else\`); b5 = text(\`ok-else\`);
} }
return block1([], [b2, b3]); const b3 = block3([], [b4, b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -106,16 +120,19 @@ exports[`t-if boolean value condition false else 1`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><span>begin</span><block-child-0/><block-child-1/><span>end</span></div>\`); let block3 = createBlock(\`<div><span>begin</span><block-child-0/><block-child-1/><span>end</span></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; const b2 = text(\`
\`);
let b4,b5;
if (ctx['condition']) { if (ctx['condition']) {
b2 = text(\`fail\`); b4 = text(\`fail\`);
} else { } else {
b3 = text(\`fail-else\`); b5 = text(\`fail-else\`);
} }
return block1([], [b2, b3]); const b3 = block3([], [b4, b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -142,35 +159,47 @@ exports[`t-if can use some boolean operators in expressions 1`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-2/><block-child-3/><block-child-4/><block-child-5/><block-child-6/><block-child-7/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
<block-child-1/>
<block-child-2/>
<block-child-3/>
<block-child-4/>
<block-child-5/>
<block-child-6/>
<block-child-7/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3,b4,b5,b6,b7,b8,b9; const b2 = text(\`
\`);
let b4,b5,b6,b7,b8,b9,b10,b11;
if (ctx['cond1']&&ctx['cond2']) { if (ctx['cond1']&&ctx['cond2']) {
b2 = text(\`and\`); b4 = text(\`and\`);
} }
if (ctx['cond1']&&ctx['cond3']) { if (ctx['cond1']&&ctx['cond3']) {
b3 = text(\`nope\`);
}
if (ctx['cond1']||ctx['cond3']) {
b4 = text(\`or\`);
}
if (ctx['cond3']||ctx['cond4']) {
b5 = text(\`nope\`); b5 = text(\`nope\`);
} }
if (ctx['cond1']||ctx['cond3']) {
b6 = text(\`or\`);
}
if (ctx['cond3']||ctx['cond4']) {
b7 = text(\`nope\`);
}
if (ctx['m']>3) { if (ctx['m']>3) {
b6 = text(\`mgt\`); b8 = text(\`mgt\`);
} }
if (ctx['n']>3) { if (ctx['n']>3) {
b7 = text(\`ngt\`); b9 = text(\`ngt\`);
} }
if (ctx['m']<3) { if (ctx['m']<3) {
b8 = text(\`mlt\`); b10 = text(\`mlt\`);
} }
if (ctx['n']<3) { if (ctx['n']<3) {
b9 = text(\`nlt\`); b11 = text(\`nlt\`);
} }
return block1([], [b2, b3, b4, b5, b6, b7, b8, b9]); const b3 = block3([], [b4, b5, b6, b7, b8, b9, b10, b11]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -407,17 +436,23 @@ exports[`t-if t-set, then t-if 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue } = helpers; let { isBoundary, withDefault, setContextValue } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
let b2; const b2 = text(\`
\`);
let b4;
setContextValue(ctx, \\"title\\", 'test'); setContextValue(ctx, \\"title\\", 'test');
if (ctx['title']) { if (ctx['title']) {
b2 = text(ctx['title']); b4 = text(ctx['title']);
} }
return block1([], [b2]); const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -428,19 +463,26 @@ exports[`t-if t-set, then t-if, part 2 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue } = helpers; let { isBoundary, withDefault, setContextValue } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block2 = createBlock(\`<span>COUCOU</span>\`);
<block-child-0/>
</div>\`);
let block4 = createBlock(\`<span>COUCOU</span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
let b2; const b2 = text(\`
\`);
let b4;
setContextValue(ctx, \\"y\\", true); setContextValue(ctx, \\"y\\", true);
setContextValue(ctx, \\"x\\", ctx['y']); setContextValue(ctx, \\"x\\", ctx['y']);
if (ctx['x']) { if (ctx['x']) {
b2 = block2(); b4 = block4();
} }
return block1([], [b2]); const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -451,22 +493,29 @@ exports[`t-if t-set, then t-if, part 3 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue } = helpers; let { isBoundary, withDefault, setContextValue } = helpers;
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); let block3 = createBlock(\`<div>
let block2 = createBlock(\`<span>AAA</span>\`);
let block3 = createBlock(\`<span>BBB</span>\`);
<block-child-0/><block-child-1/>
</div>\`);
let block4 = createBlock(\`<span>AAA</span>\`);
let block5 = createBlock(\`<span>BBB</span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
let b2,b3; const b2 = text(\`
\`);
let b4,b5;
setContextValue(ctx, \\"y\\", false); setContextValue(ctx, \\"y\\", false);
setContextValue(ctx, \\"x\\", ctx['y']); setContextValue(ctx, \\"x\\", ctx['y']);
if (ctx['x']) { if (ctx['x']) {
b2 = block2(); b4 = block4();
} else if (!ctx['x']) { } else if (!ctx['x']) {
b3 = block3(); b5 = block5();
} }
return block1([], [b2, b3]); const b3 = block3([], [b4, b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -51,7 +51,9 @@ exports[`t-key t-key directive in a list 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
let block1 = createBlock(\`<ul><block-child-0/></ul>\`); let block1 = createBlock(\`<ul>
<block-child-0/>
</ul>\`);
let block3 = createBlock(\`<li><block-text-0/></li>\`); let block3 = createBlock(\`<li><block-text-0/></li>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
@@ -63,6 +65,7 @@ exports[`t-key t-key directive in a list 1`] = `
let txt1 = ctx['beer'].name; let txt1 = ctx['beer'].name;
c_block2[i1] = withKey(block3([txt1]), key1); c_block2[i1] = withKey(block3([txt1]), key1);
} }
ctx = ctx.__proto__;
const b2 = list(c_block2); const b2 = list(c_block2);
return block1([], [b2]); return block1([], [b2]);
} }
@@ -74,18 +77,26 @@ exports[`t-key t-key on sub dom node pushes a child block in its parent 1`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); let block3 = createBlock(\`<div>
let block2 = createBlock(\`<span/>\`); <block-child-0/>
let block3 = createBlock(\`<div><h1/></div>\`); <block-child-1/>
</div>\`);
let block4 = createBlock(\`<span/>\`);
let block5 = createBlock(\`<div><h1/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; const b2 = text(\`
\`);
let b4,b5;
if (ctx['hasSpan']) { if (ctx['hasSpan']) {
b2 = block2(); b4 = block4();
} }
const tKey_1 = ctx['key']; const tKey_1 = ctx['key'];
b3 = toggler(tKey_1, block3()); b5 = toggler(tKey_1, block5());
return block1([], [b2, b3]); const b3 = block3([], [b4, b5]);
const b6 = text(\`
\`);
return multi([b2, b3, b6]);
} }
}" }"
`; `;
+94 -24
View File
@@ -34,16 +34,27 @@ exports[`t-out multiple calls to t-out 1`] = `
let { isBoundary, zero } = helpers; let { isBoundary, zero } = helpers;
const callTemplate_1 = app.getTemplate(\`sub\`); const callTemplate_1 = app.getTemplate(\`sub\`);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block2 = createBlock(\`<span>coucou</span>\`); <block-child-0/>
</div>\`);
let block6 = createBlock(\`<span>coucou</span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1; ctx[isBoundary] = 1;
const b2 = block2(); const b5 = text(\`
ctx[zero] = b2; \`);
const b3 = callTemplate_1.call(this, ctx, node, key + \`__1\`); const b6 = block6();
return block1([], [b3]); const b7 = text(\`
\`);
const b4 = multi([b5, b6, b7]);
ctx[zero] = b4;
const b8 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
ctx = ctx.__proto__;
const b3 = block3([], [b8]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -54,12 +65,19 @@ exports[`t-out multiple calls to t-out 2`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { zero } = helpers; let { zero } = helpers;
let block1 = createBlock(\`<div><block-child-0/><div>Greeter</div><block-child-1/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
<div>Greeter</div>
<block-child-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = ctx[zero]; const b2 = text(\`
const b3 = ctx[zero]; \`);
return block1([], [b2, b3]); const b4 = ctx[zero];
const b5 = ctx[zero];
const b3 = block3([], [b4, b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -161,7 +179,7 @@ exports[`t-out t-out bdom 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
ctx[\`var\`] = new LazyValue(value1, ctx, node); ctx[\`var\`] = new LazyValue(value1, ctx, this, node);
const b3 = safeOutput(ctx['var']); const b3 = safeOutput(ctx['var']);
return block1([], [b3]); return block1([], [b3]);
} }
@@ -217,13 +235,13 @@ exports[`t-out t-out on a node with a body, as a default 1`] = `
"function anonymous(app, bdom, helpers "function anonymous(app, bdom, helpers
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { safeOutput, withDefault } = helpers; let { safeOutput } = helpers;
let block1 = createBlock(\`<span><block-child-0/></span>\`); let block1 = createBlock(\`<span><block-child-0/></span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b3 = text(\`nope\`); const b3 = text(\`nope\`);
const b2 = withDefault(safeOutput(ctx['var']), b3); const b2 = safeOutput(ctx['var'], b3);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -233,14 +251,14 @@ exports[`t-out t-out on a node with a dom node in body, as a default 1`] = `
"function anonymous(app, bdom, helpers "function anonymous(app, bdom, helpers
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { safeOutput, withDefault } = helpers; let { safeOutput } = helpers;
let block1 = createBlock(\`<span><block-child-0/></span>\`); let block1 = createBlock(\`<span><block-child-0/></span>\`);
let block3 = createBlock(\`<div>nope</div>\`); let block3 = createBlock(\`<div>nope</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b3 = block3(); const b3 = block3();
const b2 = withDefault(safeOutput(ctx['var']), b3); const b2 = safeOutput(ctx['var'], b3);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -297,10 +315,13 @@ exports[`t-out t-out switch markup on bdom 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, LazyValue, safeOutput } = helpers; let { isBoundary, withDefault, LazyValue, safeOutput } = helpers;
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); let block1 = createBlock(\`<div>
<block-child-0/><block-child-1/>
</div>\`);
let block2 = createBlock(\`<ol>set</ol>\`); let block2 = createBlock(\`<ol>set</ol>\`);
let block3 = createBlock(\`<span><block-child-0/></span>\`);
let block5 = createBlock(\`<span><block-child-0/></span>\`); let block5 = createBlock(\`<span><block-child-0/></span>\`);
let block10 = createBlock(\`<span><block-child-0/></span>\`);
function value1(ctx, node, key = \\"\\") { function value1(ctx, node, key = \\"\\") {
return block2(); return block2();
@@ -309,16 +330,26 @@ exports[`t-out t-out switch markup on bdom 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
let b3,b5; let b3,b8;
ctx[\`bdom\`] = new LazyValue(value1, ctx, node); ctx[\`bdom\`] = new LazyValue(value1, ctx, this, node);
if (ctx['hasBdom']) { if (ctx['hasBdom']) {
const b4 = safeOutput(ctx['bdom']); const b4 = text(\`
b3 = block3([], [b4]); \`);
const b6 = safeOutput(ctx['bdom']);
const b5 = block5([], [b6]);
const b7 = text(\`
\`);
b3 = multi([b4, b5, b7]);
} else { } else {
const b6 = safeOutput(ctx['var']); const b9 = text(\`
b5 = block5([], [b6]); \`);
const b11 = safeOutput(ctx['var']);
const b10 = block10([], [b11]);
const b12 = text(\`
\`);
b8 = multi([b9, b10, b12]);
} }
return block1([], [b3, b5]); return block1([], [b3, b8]);
} }
}" }"
`; `;
@@ -407,6 +438,45 @@ exports[`t-out t-out with just a t-set t-value in body 1`] = `
}" }"
`; `;
exports[`t-out t-out with the 0 number 1`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { safeOutput } = helpers;
return function template(ctx, node, key = \\"\\") {
return safeOutput(ctx['var']);
}
}"
`;
exports[`t-out t-out with the 0 number, in a p 1`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { safeOutput } = helpers;
let block1 = createBlock(\`<p><block-child-0/></p>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = safeOutput(ctx['var']);
return block1([], [b2]);
}
}"
`;
exports[`t-out top level t-out with undefined 1`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { safeOutput } = helpers;
return function template(ctx, node, key = \\"\\") {
return safeOutput(ctx['var']);
}
}"
`;
exports[`t-out variable 1`] = ` exports[`t-out variable 1`] = `
"function anonymous(app, bdom, helpers "function anonymous(app, bdom, helpers
) { ) {
+42 -13
View File
@@ -82,17 +82,27 @@ exports[`t-ref ref in a t-if 1`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block2 = createBlock(\`<span block-ref=\\"0\\"/>\`); <block-child-0/>
</div>\`);
let block6 = createBlock(\`<span block-ref=\\"0\\"/>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const refs = ctx.__owl__.refs; const refs = ctx.__owl__.refs;
const ref1 = (el) => refs[\`name\`] = el; const ref1 = (el) => refs[\`name\`] = el;
let b2; const b2 = text(\`
\`);
let b4;
if (ctx['condition']) { if (ctx['condition']) {
b2 = block2([ref1]); const b5 = text(\`
\`);
const b6 = block6([ref1]);
const b7 = text(\`
\`);
b4 = multi([b5, b6, b7]);
} }
return block1([], [b2]); const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -103,8 +113,10 @@ exports[`t-ref refs in a loop 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div>
let block3 = createBlock(\`<div block-ref=\\"0\\"><block-text-1/></div>\`); <block-child-0/>
</div>\`);
let block5 = createBlock(\`<div block-ref=\\"0\\"><block-text-1/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const refs = ctx.__owl__.refs; const refs = ctx.__owl__.refs;
@@ -113,12 +125,18 @@ exports[`t-ref refs in a loop 1`] = `
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block2; i1++) {
ctx[\`item\`] = v_block2[i1]; ctx[\`item\`] = v_block2[i1];
const key1 = ctx['item']; const key1 = ctx['item'];
const b4 = text(\`
\`);
const tKey_1 = ctx['item']; const tKey_1 = ctx['item'];
const v1 = ctx['item']; const v1 = ctx['item'];
let ref1 = (el) => refs[(v1)] = el; let ref1 = (el) => refs[(v1)] = el;
let txt1 = ctx['item']; let txt1 = ctx['item'];
c_block2[i1] = withKey(block3([ref1, txt1]), tKey_1 + key1); const b5 = toggler(tKey_1, block5([ref1, txt1]));
const b6 = text(\`
\`);
c_block2[i1] = withKey(multi([b4, b5, b6]), key1);
} }
ctx = ctx.__proto__;
const b2 = list(c_block2); const b2 = list(c_block2);
return block1([], [b2]); return block1([], [b2]);
} }
@@ -130,18 +148,29 @@ exports[`t-ref two refs, one in a t-if 1`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><block-child-0/><p block-ref=\\"0\\"/></div>\`); let block3 = createBlock(\`<div>
let block2 = createBlock(\`<span block-ref=\\"0\\"/>\`); <block-child-0/>
<p block-ref=\\"0\\"/>
</div>\`);
let block6 = createBlock(\`<span block-ref=\\"0\\"/>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const refs = ctx.__owl__.refs; const refs = ctx.__owl__.refs;
const ref1 = (el) => refs[\`name\`] = el; const ref1 = (el) => refs[\`name\`] = el;
const ref2 = (el) => refs[\`p\`] = el; const ref2 = (el) => refs[\`p\`] = el;
let b2; const b2 = text(\`
\`);
let b4;
if (ctx['condition']) { if (ctx['condition']) {
b2 = block2([ref1]); const b5 = text(\`
\`);
const b6 = block6([ref1]);
const b7 = text(\`
\`);
b4 = multi([b5, b6, b7]);
} }
return block1([ref2], [b2]); const b3 = block3([ref2], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
+293 -84
View File
@@ -94,20 +94,33 @@ exports[`t-set set from body literal (with t-if/t-else 1`] = `
let { isBoundary, withDefault, LazyValue } = helpers; let { isBoundary, withDefault, LazyValue } = helpers;
function value1(ctx, node, key = \\"\\") { function value1(ctx, node, key = \\"\\") {
let b2,b3; let b5,b6,b7,b8;
b5 = text(\`
\`);
if (ctx['condition']) { if (ctx['condition']) {
b2 = text(\`true\`); b6 = text(\`true\`);
} else { } else {
b3 = text(\`false\`); b7 = text(\`false\`);
} }
return multi([b2, b3]); b8 = text(\`
\`);
return multi([b5, b6, b7, b8]);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
ctx[\`value\`] = new LazyValue(value1, ctx, node); const b2 = text(\`
return text(ctx['value']); \`);
const b3 = text(\`
\`);
ctx[\`value\`] = new LazyValue(value1, ctx, this, node);
const b9 = text(\`
\`);
const b10 = text(ctx['value']);
const b11 = text(\`
\`);
return multi([b2, b3, b9, b10, b11]);
} }
}" }"
`; `;
@@ -142,7 +155,7 @@ exports[`t-set set from body lookup 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
ctx[\`stuff\`] = new LazyValue(value1, ctx, node); ctx[\`stuff\`] = new LazyValue(value1, ctx, this, node);
let txt1 = ctx['stuff']; let txt1 = ctx['stuff'];
return block1([txt1]); return block1([txt1]);
} }
@@ -173,17 +186,23 @@ exports[`t-set t-set and t-if 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue } = helpers; let { isBoundary, withDefault, setContextValue } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
let b2; const b2 = text(\`
\`);
let b4;
setContextValue(ctx, \\"v\\", ctx['value']); setContextValue(ctx, \\"v\\", ctx['value']);
if (ctx['v']==='ok') { if (ctx['v']==='ok') {
b2 = text(\`grimbergen\`); b4 = text(\`grimbergen\`);
} }
return block1([], [b2]); const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -194,22 +213,35 @@ exports[`t-set t-set body is evaluated immediately 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue, LazyValue, safeOutput } = helpers; let { isBoundary, withDefault, setContextValue, LazyValue, safeOutput } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block2 = createBlock(\`<span><block-text-0/></span>\`);
<block-child-0/>
</div>\`);
let block6 = createBlock(\`<span><block-text-0/></span>\`);
function value1(ctx, node, key = \\"\\") { function value1(ctx, node, key = \\"\\") {
const b5 = text(\`
\`);
let txt1 = ctx['v1']; let txt1 = ctx['v1'];
return block2([txt1]); const b6 = block6([txt1]);
const b7 = text(\`
\`);
return multi([b5, b6, b7]);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
setContextValue(ctx, \\"v1\\", 'before'); setContextValue(ctx, \\"v1\\", 'before');
ctx[\`v2\`] = new LazyValue(value1, ctx, node); ctx[\`v2\`] = new LazyValue(value1, ctx, this, node);
setContextValue(ctx, \\"v1\\", 'after'); setContextValue(ctx, \\"v1\\", 'after');
const b3 = safeOutput(ctx['v2']); const b8 = safeOutput(ctx['v2']);
return block1([], [b3]); const b3 = block3([], [b8]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -221,16 +253,26 @@ exports[`t-set t-set can't alter from within callee 1`] = `
let { isBoundary, withDefault, setContextValue } = helpers; let { isBoundary, withDefault, setContextValue } = helpers;
const callTemplate_1 = app.getTemplate(\`sub\`); const callTemplate_1 = app.getTemplate(\`sub\`);
let block1 = createBlock(\`<div><p><block-text-0/></p><block-child-0/><p><block-text-1/></p></div>\`); let block3 = createBlock(\`<div>
<p><block-text-0/></p>
<block-child-0/>
<p><block-text-1/></p>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
setContextValue(ctx, \\"iter\\", 'source'); setContextValue(ctx, \\"iter\\", 'source');
let txt1 = ctx['iter']; let txt1 = ctx['iter'];
const b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`); const b4 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
let txt2 = ctx['iter']; let txt2 = ctx['iter'];
return block1([txt1, txt2], [b2]); const b3 = block3([txt1, txt2], [b4]);
const b5 = text(\`
\`);
return multi([b2, b3, b5]);
} }
}" }"
`; `;
@@ -258,23 +300,39 @@ exports[`t-set t-set can't alter in t-call body 1`] = `
"function anonymous(app, bdom, helpers "function anonymous(app, bdom, helpers
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue } = helpers; let { isBoundary, withDefault, setContextValue, zero } = helpers;
const callTemplate_1 = app.getTemplate(\`sub\`); const callTemplate_1 = app.getTemplate(\`sub\`);
let block1 = createBlock(\`<div><p><block-text-0/></p><block-child-0/><p><block-text-1/></p></div>\`); let block3 = createBlock(\`<div>
<p><block-text-0/></p>
<block-child-0/>
<p><block-text-1/></p>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
setContextValue(ctx, \\"iter\\", 'source'); setContextValue(ctx, \\"iter\\", 'source');
let txt1 = ctx['iter']; let txt1 = ctx['iter'];
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1; ctx[isBoundary] = 1;
const b5 = text(\`
\`);
setContextValue(ctx, \\"iter\\", 'inCall'); setContextValue(ctx, \\"iter\\", 'inCall');
const b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`); const b6 = text(\`
\`);
const b4 = multi([b5, b6]);
ctx[zero] = b4;
const b7 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
ctx = ctx.__proto__; ctx = ctx.__proto__;
let txt2 = ctx['iter']; let txt2 = ctx['iter'];
return block1([txt1, txt2], [b2]); const b3 = block3([txt1, txt2], [b7]);
const b8 = text(\`
\`);
return multi([b2, b3, b8]);
} }
}" }"
`; `;
@@ -322,15 +380,22 @@ exports[`t-set t-set evaluates an expression only once 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue } = helpers; let { isBoundary, withDefault, setContextValue } = helpers;
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`); let block3 = createBlock(\`<div>
<block-text-0/>
<block-text-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
setContextValue(ctx, \\"v\\", ctx['value']+' artois'); setContextValue(ctx, \\"v\\", ctx['value']+' artois');
let txt1 = ctx['v']; let txt1 = ctx['v'];
let txt2 = ctx['v']; let txt2 = ctx['v'];
return block1([txt1, txt2]); const b3 = block3([txt1, txt2]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -341,26 +406,42 @@ exports[`t-set t-set outside modified in t-foreach 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers; let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/><p>EndLoop: <block-text-0/></p></div>\`); let block3 = createBlock(\`<div>
let block3 = createBlock(\`<p>InLoop: <block-text-0/></p>\`);
<block-child-0/>
<p>EndLoop: <block-text-0/></p>
</div>\`);
let block7 = createBlock(\`<p>InLoop: <block-text-0/></p>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
setContextValue(ctx, \\"iter\\", 0); setContextValue(ctx, \\"iter\\", 0);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(['a','b']);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(['a','b']);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`val\`] = v_block2[i1]; ctx[\`val\`] = v_block4[i1];
const key1 = ctx['val']; const key1 = ctx['val'];
const b6 = text(\`
\`);
let txt1 = ctx['iter']; let txt1 = ctx['iter'];
c_block2[i1] = withKey(block3([txt1]), key1); const b7 = block7([txt1]);
const b8 = text(\`
\`);
setContextValue(ctx, \\"iter\\", ctx['iter']+1); setContextValue(ctx, \\"iter\\", ctx['iter']+1);
const b9 = text(\`
\`);
c_block4[i1] = withKey(multi([b6, b7, b8, b9]), key1);
} }
ctx = ctx.__proto__; ctx = ctx.__proto__;
const b2 = list(c_block2); const b4 = list(c_block4);
let txt2 = ctx['iter']; let txt2 = ctx['iter'];
return block1([txt2], [b2]); const b3 = block3([txt2], [b4]);
const b10 = text(\`
\`);
return multi([b2, b3, b10]);
} }
}" }"
`; `;
@@ -371,26 +452,42 @@ exports[`t-set t-set outside modified in t-foreach increment-after operator 1`]
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers; let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/><p>EndLoop: <block-text-0/></p></div>\`); let block3 = createBlock(\`<div>
let block3 = createBlock(\`<p>InLoop: <block-text-0/></p>\`);
<block-child-0/>
<p>EndLoop: <block-text-0/></p>
</div>\`);
let block7 = createBlock(\`<p>InLoop: <block-text-0/></p>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
setContextValue(ctx, \\"iter\\", 0); setContextValue(ctx, \\"iter\\", 0);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(['a','b']);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(['a','b']);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`val\`] = v_block2[i1]; ctx[\`val\`] = v_block4[i1];
const key1 = ctx['val']; const key1 = ctx['val'];
const b6 = text(\`
\`);
let txt1 = ctx['iter']; let txt1 = ctx['iter'];
c_block2[i1] = withKey(block3([txt1]), key1); const b7 = block7([txt1]);
const b8 = text(\`
\`);
setContextValue(ctx, \\"iter\\", ctx['iter']++); setContextValue(ctx, \\"iter\\", ctx['iter']++);
const b9 = text(\`
\`);
c_block4[i1] = withKey(multi([b6, b7, b8, b9]), key1);
} }
ctx = ctx.__proto__; ctx = ctx.__proto__;
const b2 = list(c_block2); const b4 = list(c_block4);
let txt2 = ctx['iter']; let txt2 = ctx['iter'];
return block1([txt2], [b2]); const b3 = block3([txt2], [b4]);
const b10 = text(\`
\`);
return multi([b2, b3, b10]);
} }
}" }"
`; `;
@@ -401,26 +498,42 @@ exports[`t-set t-set outside modified in t-foreach increment-before operator 1`]
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers; let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/><p>EndLoop: <block-text-0/></p></div>\`); let block3 = createBlock(\`<div>
let block3 = createBlock(\`<p>InLoop: <block-text-0/></p>\`);
<block-child-0/>
<p>EndLoop: <block-text-0/></p>
</div>\`);
let block7 = createBlock(\`<p>InLoop: <block-text-0/></p>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
setContextValue(ctx, \\"iter\\", 0); setContextValue(ctx, \\"iter\\", 0);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(['a','b']);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(['a','b']);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`val\`] = v_block2[i1]; ctx[\`val\`] = v_block4[i1];
const key1 = ctx['val']; const key1 = ctx['val'];
const b6 = text(\`
\`);
let txt1 = ctx['iter']; let txt1 = ctx['iter'];
c_block2[i1] = withKey(block3([txt1]), key1); const b7 = block7([txt1]);
const b8 = text(\`
\`);
setContextValue(ctx, \\"iter\\", ++ctx['iter']); setContextValue(ctx, \\"iter\\", ++ctx['iter']);
const b9 = text(\`
\`);
c_block4[i1] = withKey(multi([b6, b7, b8, b9]), key1);
} }
ctx = ctx.__proto__; ctx = ctx.__proto__;
const b2 = list(c_block2); const b4 = list(c_block4);
let txt2 = ctx['iter']; let txt2 = ctx['iter'];
return block1([txt2], [b2]); const b3 = block3([txt2], [b4]);
const b10 = text(\`
\`);
return multi([b2, b3, b10]);
} }
}" }"
`; `;
@@ -431,25 +544,35 @@ exports[`t-set t-set should reuse variable if possible 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers; let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block3 = createBlock(\`<div><span>v<block-text-0/></span></div>\`);
<block-child-0/>
</div>\`);
let block5 = createBlock(\`<div>
<span>v<block-text-0/></span>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
setContextValue(ctx, \\"v\\", 1); setContextValue(ctx, \\"v\\", 1);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['list']);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['list']);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`elem\`] = v_block2[i1]; ctx[\`elem\`] = v_block4[i1];
ctx[\`elem_index\`] = i1; ctx[\`elem_index\`] = i1;
const key1 = ctx['elem_index']; const key1 = ctx['elem_index'];
let txt1 = ctx['v']; let txt1 = ctx['v'];
setContextValue(ctx, \\"v\\", ctx['elem']); setContextValue(ctx, \\"v\\", ctx['elem']);
c_block2[i1] = withKey(block3([txt1]), key1); c_block4[i1] = withKey(block5([txt1]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -460,20 +583,26 @@ exports[`t-set t-set with content and sub t-esc 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, LazyValue } = helpers; let { isBoundary, withDefault, LazyValue } = helpers;
let block1 = createBlock(\`<div><block-text-0/></div>\`); let block3 = createBlock(\`<div>
<block-text-0/>
</div>\`);
function value1(ctx, node, key = \\"\\") { function value1(ctx, node, key = \\"\\") {
const b3 = text(ctx['beep']); const b5 = text(ctx['beep']);
const b4 = text(\` boop\`); const b6 = text(\` boop\`);
return multi([b3, b4]); return multi([b5, b6]);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
ctx[\`setvar\`] = new LazyValue(value1, ctx, node); const b2 = text(\`
\`);
ctx[\`setvar\`] = new LazyValue(value1, ctx, this, node);
let txt1 = ctx['setvar']; let txt1 = ctx['setvar'];
return block1([txt1]); const b3 = block3([txt1]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -484,24 +613,39 @@ exports[`t-set t-set with t-value (falsy) and body 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue, LazyValue, safeOutput } = helpers; let { isBoundary, withDefault, setContextValue, LazyValue, safeOutput } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block2 = createBlock(\`<span><block-text-0/></span>\`);
<block-child-0/>
</div>\`);
let block6 = createBlock(\`<span><block-text-0/></span>\`);
function value1(ctx, node, key = \\"\\") { function value1(ctx, node, key = \\"\\") {
const b5 = text(\`
\`);
let txt1 = ctx['v1']; let txt1 = ctx['v1'];
return block2([txt1]); const b6 = block6([txt1]);
const b7 = text(\`
\`);
return multi([b5, b6, b7]);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
setContextValue(ctx, \\"v3\\", false); setContextValue(ctx, \\"v3\\", false);
setContextValue(ctx, \\"v1\\", 'before'); setContextValue(ctx, \\"v1\\", 'before');
ctx[\`v2\`] = withDefault(ctx['v3'], new LazyValue(value1, ctx, node)); ctx[\`v2\`] = withDefault(ctx['v3'], new LazyValue(value1, ctx, this, node));
setContextValue(ctx, \\"v1\\", 'after'); setContextValue(ctx, \\"v1\\", 'after');
setContextValue(ctx, \\"v3\\", true); setContextValue(ctx, \\"v3\\", true);
const b3 = safeOutput(ctx['v2']); const b8 = safeOutput(ctx['v2']);
return block1([], [b3]); const b3 = block3([], [b8]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -512,24 +656,73 @@ exports[`t-set t-set with t-value (truthy) and body 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue, LazyValue, safeOutput } = helpers; let { isBoundary, withDefault, setContextValue, LazyValue, safeOutput } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block2 = createBlock(\`<span><block-text-0/></span>\`);
<block-child-0/>
</div>\`);
let block6 = createBlock(\`<span><block-text-0/></span>\`);
function value1(ctx, node, key = \\"\\") { function value1(ctx, node, key = \\"\\") {
const b5 = text(\`
\`);
let txt1 = ctx['v1']; let txt1 = ctx['v1'];
return block2([txt1]); const b6 = block6([txt1]);
const b7 = text(\`
\`);
return multi([b5, b6, b7]);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
setContextValue(ctx, \\"v3\\", 'Truthy'); setContextValue(ctx, \\"v3\\", 'Truthy');
setContextValue(ctx, \\"v1\\", 'before'); setContextValue(ctx, \\"v1\\", 'before');
ctx[\`v2\`] = withDefault(ctx['v3'], new LazyValue(value1, ctx, node)); ctx[\`v2\`] = withDefault(ctx['v3'], new LazyValue(value1, ctx, this, node));
setContextValue(ctx, \\"v1\\", 'after'); setContextValue(ctx, \\"v1\\", 'after');
setContextValue(ctx, \\"v3\\", false); setContextValue(ctx, \\"v3\\", false);
const b3 = safeOutput(ctx['v2']); const b8 = safeOutput(ctx['v2']);
return block1([], [b3]); const b3 = block3([], [b8]);
return multi([b2, b3]);
}
}"
`;
exports[`t-set t-set, multiple t-ifs, and a specific configuration 1`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue } = helpers;
let block3 = createBlock(\`<p>
<div>
<span>First div</span>
</div>
<div>
<block-child-0/>
</div>
</p>\`);
return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx);
ctx[isBoundary] = 1
const b2 = text(\`
\`);
let b4;
if (ctx['flag']) {
setContextValue(ctx, \\"bouh\\", 2);
}
if (!ctx['flag']) {
b4 = text(\`Second\`);
}
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -540,18 +733,24 @@ exports[`t-set t-set, t-if, and mix of expression/body lookup, 1 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue } = helpers; let { isBoundary, withDefault, setContextValue } = helpers;
let block1 = createBlock(\`<div><block-child-0/><block-child-0/><block-text-0/></div>\`); let block3 = createBlock(\`<div>
<block-text-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
if (ctx['flag']) { if (ctx['flag']) {
setContextValue(ctx, \\"ourvar\\", \`1\`); setContextValue(ctx, \\"ourvar\\", \`1\`);
} else { } else {
setContextValue(ctx, \\"ourvar\\", 0); setContextValue(ctx, \\"ourvar\\", 0);
} }
let txt1 = ctx['ourvar']; let txt1 = ctx['ourvar'];
return block1([txt1]); const b3 = block3([txt1]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -562,18 +761,24 @@ exports[`t-set t-set, t-if, and mix of expression/body lookup, 2 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue } = helpers; let { isBoundary, withDefault, setContextValue } = helpers;
let block1 = createBlock(\`<div><block-child-0/><block-child-0/><block-text-0/></div>\`); let block3 = createBlock(\`<div>
<block-text-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
if (ctx['flag']) { if (ctx['flag']) {
setContextValue(ctx, \\"ourvar\\", 1); setContextValue(ctx, \\"ourvar\\", 1);
} else { } else {
setContextValue(ctx, \\"ourvar\\", \`0\`); setContextValue(ctx, \\"ourvar\\", \`0\`);
} }
let txt1 = ctx['ourvar']; let txt1 = ctx['ourvar'];
return block1([txt1]); const b3 = block3([txt1]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -587,14 +792,18 @@ exports[`t-set t-set, t-if, and mix of expression/body lookup, 3 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
let b2; let b2,b3,b4;
b2 = text(\`
\`);
if (ctx['flag']) { if (ctx['flag']) {
setContextValue(ctx, \\"ourvar\\", 1); setContextValue(ctx, \\"ourvar\\", 1);
} else { } else {
setContextValue(ctx, \\"ourvar\\", \`0\`); setContextValue(ctx, \\"ourvar\\", \`0\`);
} }
b2 = text(ctx['ourvar']); b3 = text(\`
return multi([b2]); \`);
b4 = text(ctx['ourvar']);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -615,7 +824,7 @@ exports[`t-set value priority (with non text body 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
ctx[\`value\`] = withDefault(1, new LazyValue(value1, ctx, node)); ctx[\`value\`] = withDefault(1, new LazyValue(value1, ctx, this, node));
let txt1 = ctx['value']; let txt1 = ctx['value'];
return block1([txt1]); return block1([txt1]);
} }
@@ -75,11 +75,18 @@ exports[`qweb t-tag with multiple child nodes 1`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = tag => createBlock(\`<\${tag || 't'}> pear <span>apple</span> strawberry </\${tag || 't'}>\`); let block3 = tag => createBlock(\`<\${tag || 't'}>
pear
<span>apple</span>
strawberry
</\${tag || 't'}>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const tag1 = ctx['tag']; const tag1 = ctx['tag'];
return toggler(tag1, block1(tag1)()); const b3 = toggler(tag1, block3(tag1)());
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -5,10 +5,15 @@ exports[`translation support can set and remove translatable attributes 1`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div tomato=\\"word\\" potato=\\"mot\\" title=\\"mot\\" label=\\"word\\">text</div>\`); let block3 = createBlock(\`<div tomato=\\"word\\" potato=\\"mot\\" title=\\"mot\\" label=\\"word\\">text</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return block1(); const b2 = text(\`
\`);
const b3 = block3();
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -31,10 +36,18 @@ exports[`translation support does not translate node content if disabled 1`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><span>mot</span><span>word</span></div>\`); let block3 = createBlock(\`<div>
<span>mot</span>
<span>word</span>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return block1(); const b2 = text(\`
\`);
const b3 = block3();
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -44,10 +57,21 @@ exports[`translation support some attributes are translated 1`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><p label=\\"mot\\">mot</p><p title=\\"mot\\">mot</p><p placeholder=\\"mot\\">mot</p><p alt=\\"mot\\">mot</p><p something=\\"word\\">mot</p></div>\`); let block3 = createBlock(\`<div>
<p label=\\"mot\\">mot</p>
<p title=\\"mot\\">mot</p>
<p placeholder=\\"mot\\">mot</p>
<p alt=\\"mot\\">mot</p>
<p something=\\"word\\">mot</p>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return block1(); const b2 = text(\`
\`);
const b3 = block3();
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -57,10 +81,15 @@ exports[`translation support translation is done on the trimmed text, with extra
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div> mot </div>\`); let block3 = createBlock(\`<div> mot </div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return block1(); const b2 = text(\`
\`);
const b3 = block3();
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -61,7 +61,8 @@ exports[`white space handling pre inside a div with a new line 1`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><pre>SomeText</pre></div>\`); let block1 = createBlock(\`<div><pre>SomeText</pre>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return block1(); return block1();
@@ -87,7 +88,9 @@ exports[`white space handling whitespace only text nodes with newlines are remov
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><span>abc</span></div>\`); let block1 = createBlock(\`<div>
<span>abc</span>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return block1(); return block1();
+30
View File
@@ -63,6 +63,24 @@ describe("attributes", () => {
expect(result).toBe(`<div></div>`); expect(result).toBe(`<div></div>`);
}); });
test("dynamic class attribute which is only a space", () => {
const template = `<div t-att-class="c"/>`;
const result = renderToString(template, { c: " " });
expect(result).toBe(`<div></div>`);
});
test("dynamic class attribute with multiple consecutive spaces", () => {
const template = `<div t-att-class="c"/>`;
const result = renderToString(template, { c: "a b" });
expect(result).toBe(`<div class="a b"></div>`);
});
test("dynamic class attribute that starts and ends with a space", () => {
const template = `<div t-att-class="c"/>`;
const result = renderToString(template, { c: " a " });
expect(result).toBe(`<div class="a"></div>`);
});
test("dynamic undefined generic attribute", () => { test("dynamic undefined generic attribute", () => {
const template = `<div t-att-thing="c"/>`; const template = `<div t-att-thing="c"/>`;
const result = renderToString(template, { c: undefined }); const result = renderToString(template, { c: undefined });
@@ -260,6 +278,14 @@ describe("attributes", () => {
const template = `<div class="static" t-att-class="{a: b, c: d, e: f}"/>`; const template = `<div class="static" t-att-class="{a: b, c: d, e: f}"/>`;
const result = renderToString(template, { b: true, d: false, f: true }); const result = renderToString(template, { b: true, d: false, f: true });
expect(result).toBe(`<div class="static a e"></div>`); expect(result).toBe(`<div class="static a e"></div>`);
// leading and trailing space in the key
expect(renderToString(`<div t-att-class="{' a ': value}" />`, { value: true })).toBe(
'<div class="a"></div>'
);
// whitespace only key
expect(renderToString(`<div t-att-class="{' ': value}" />`, { value: true })).toBe(
"<div></div>"
);
}); });
test("t-att-class with multiple classes", () => { test("t-att-class with multiple classes", () => {
@@ -269,6 +295,10 @@ describe("attributes", () => {
expect(renderToString(`<div t-att-class="{['a b c']: value}" />`, { value: true })).toBe( expect(renderToString(`<div t-att-class="{['a b c']: value}" />`, { value: true })).toBe(
'<div class="a b c"></div>' '<div class="a b c"></div>'
); );
// multiple spaces between classes
expect(renderToString(`<div t-att-class="{'a b c': value}" />`, { value: true })).toBe(
'<div class="a b c"></div>'
);
}); });
test("t-att-class with multiple classes, some of which are duplicate", () => { test("t-att-class with multiple classes, some of which are duplicate", () => {
@@ -221,4 +221,11 @@ describe("expression evaluation", () => {
expect(compileExpr("a.c in b")).toBe("ctx['a'].c in ctx['b']"); expect(compileExpr("a.c in b")).toBe("ctx['a'].c in ctx['b']");
expect(compileExpr("typeof val")).toBe("typeof ctx['val']"); expect(compileExpr("typeof val")).toBe("typeof ctx['val']");
}); });
test("binary operators", () => {
expect(compileExpr("1 | 1")).toBe("1|1");
expect(compileExpr("1 & 1")).toBe("1&1");
expect(compileExpr("1 ^ 1")).toBe("1^1");
expect(compileExpr("~1")).toBe("~1");
});
}); });
+15 -1
View File
@@ -1033,6 +1033,7 @@ describe("qweb parser", () => {
type: ASTType.TCall, type: ASTType.TCall,
name: "blap", name: "blap",
body: null, body: null,
context: null,
}, },
memo: "", memo: "",
hasNoFirst: false, hasNoFirst: false,
@@ -1070,6 +1071,7 @@ describe("qweb parser", () => {
type: ASTType.TCall, type: ASTType.TCall,
name: "blabla", name: "blabla",
body: null, body: null,
context: null,
}); });
}); });
@@ -1077,10 +1079,20 @@ describe("qweb parser", () => {
expect(parse(`<t t-call="sub">ok</t>`)).toEqual({ expect(parse(`<t t-call="sub">ok</t>`)).toEqual({
type: ASTType.TCall, type: ASTType.TCall,
name: "sub", name: "sub",
context: null,
body: [{ type: ASTType.Text, value: "ok" }], body: [{ type: ASTType.Text, value: "ok" }],
}); });
}); });
test("t-call expression with t-call-context", async () => {
expect(parse(`<t t-call="blabla" t-call-context="someContext"/>`)).toEqual({
type: ASTType.TCall,
name: "blabla",
body: null,
context: "someContext",
});
});
test("t-call on a div node", async () => { test("t-call on a div node", async () => {
expect(parse(`<div t-call="blabla" />`)).toEqual({ expect(parse(`<div t-call="blabla" />`)).toEqual({
type: ASTType.DomNode, type: ASTType.DomNode,
@@ -1096,6 +1108,7 @@ describe("qweb parser", () => {
type: ASTType.TCall, type: ASTType.TCall,
name: "blabla", name: "blabla",
body: null, body: null,
context: null,
}, },
], ],
}); });
@@ -1111,6 +1124,7 @@ describe("qweb parser", () => {
type: ASTType.TCall, type: ASTType.TCall,
name: "blabla", name: "blabla",
body: null, body: null,
context: null,
}, },
}); });
}); });
@@ -1547,7 +1561,7 @@ describe("qweb parser", () => {
on: null, on: null,
slots: { slots: {
default: { default: {
content: { body: null, name: "subTemplate", type: ASTType.TCall }, content: { body: null, name: "subTemplate", type: ASTType.TCall, context: null },
attrs: null, attrs: null,
scope: null, scope: null,
on: null, on: null,
+34
View File
@@ -445,4 +445,38 @@ describe("t-call (template calling)", () => {
const expected2 = "<div><bar>quux</bar></div>"; const expected2 = "<div><bar>quux</bar></div>";
expect(context.renderToString("main", { template: "bar", val: "quux" })).toBe(expected2); expect(context.renderToString("main", { template: "bar", val: "quux" })).toBe(expected2);
}); });
test("t-call-context", () => {
const context = new TestContext();
context.addTemplate("sub", `<span><t t-esc="value"/></span>`);
context.addTemplate("main", `<t t-call="sub" t-call-context="obj"/>`);
expect(context.renderToString("main", { obj: { value: 123 } })).toBe("<span>123</span>");
});
test("t-call on a div with t-call-context", () => {
const context = new TestContext();
context.addTemplate("sub", `<span><t t-esc="value"/></span>`);
context.addTemplate("main", `<div t-call="sub" t-call-context="obj"/>`);
expect(context.renderToString("main", { obj: { value: 123 } })).toBe(
"<div><span>123</span></div>"
);
});
test("t-call-context and value in body", () => {
const context = new TestContext();
context.addTemplate("sub", `<span><t t-esc="value1"/><t t-esc="value2"/></span>`);
context.addTemplate(
"main",
`
<t t-call="sub" t-call-context="obj">
<t t-set="value2" t-value="aaron" />
</t>`
);
expect(context.renderToString("main", { obj: { value1: 123 }, aaron: "lucas" })).toBe(
"<span>123lucas</span>"
);
});
}); });
+15
View File
@@ -67,6 +67,21 @@ describe("t-esc", () => {
); );
}); });
test("t-esc with the 0 number", () => {
const template = `<t t-esc="var"/>`;
expect(renderToString(template, { var: 0 })).toBe("0");
});
test("t-esc with the 0 number, in a p", () => {
const template = `<p><t t-esc="var"/></p>`;
expect(renderToString(template, { var: 0 })).toBe("<p>0</p>");
});
test("top level t-esc with undefined", () => {
const template = `<t t-esc="var"/>`;
expect(renderToString(template, { var: undefined })).toBe("");
});
test("falsy values in text nodes", () => { test("falsy values in text nodes", () => {
const template = ` const template = `
<t t-esc="v1"/>:<t t-esc="v2"/>:<t t-esc="v3"/>:<t t-esc="v4"/>:<t t-esc="v5"/>`; <t t-esc="v1"/>:<t t-esc="v2"/>:<t t-esc="v3"/>:<t t-esc="v4"/>:<t t-esc="v5"/>`;
+15
View File
@@ -47,6 +47,21 @@ describe("t-out", () => {
expect(renderToString(template, { var: new String("ok") })).toBe("<span>ok</span>"); expect(renderToString(template, { var: new String("ok") })).toBe("<span>ok</span>");
}); });
test("t-out with the 0 number", () => {
const template = `<t t-out="var"/>`;
expect(renderToString(template, { var: 0 })).toBe("0");
});
test("t-out with the 0 number, in a p", () => {
const template = `<p><t t-out="var"/></p>`;
expect(renderToString(template, { var: 0 })).toBe("<p>0</p>");
});
test("top level t-out with undefined", () => {
const template = `<t t-out="var"/>`;
expect(renderToString(template, { var: undefined })).toBe("");
});
test("with an extended String class", () => { test("with an extended String class", () => {
class LoveString extends String { class LoveString extends String {
valueOf(): string { valueOf(): string {
+16
View File
@@ -33,6 +33,22 @@ describe("t-set", () => {
expect(renderToString(template, { value: "ok" })).toBe("<div>grimbergen</div>"); expect(renderToString(template, { value: "ok" })).toBe("<div>grimbergen</div>");
}); });
test("t-set, multiple t-ifs, and a specific configuration", () => {
const template = `
<p>
<div>
<t t-if="flag" t-set="bouh" t-value="2"/>
<span>First div</span>
</div>
<div>
<t t-if="!flag">Second</t>
</div>
</p>`;
expect(renderToString(template)).toBe(
"<p><div><span>First div</span></div><div>Second</div></p>"
);
});
test("set from body literal", () => { test("set from body literal", () => {
const template = `<t><t t-set="value">ok</t><t t-esc="value"/></t>`; const template = `<t><t t-set="value">ok</t><t t-esc="value"/></t>`;
expect(renderToString(template)).toBe("ok"); expect(renderToString(template)).toBe("ok");
+235 -111
View File
@@ -8,7 +8,7 @@ exports[`basics GrandChild display is controlled by its GrandParent 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const Comp1 = ctx['myComp']; const Comp1 = ctx['myComp'];
return toggler(Comp1, comp1({displayGrandChild: ctx['displayGrandChild']}, key + \`__1\`, node, ctx, Comp1)); return toggler(Comp1, comp1({displayGrandChild: ctx['displayGrandChild']}, key + \`__1\`, node, this, Comp1));
} }
}" }"
`; `;
@@ -22,7 +22,7 @@ exports[`basics GrandChild display is controlled by its GrandParent 2`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; let b2;
if (ctx['props'].displayGrandChild) { if (ctx['props'].displayGrandChild) {
b2 = comp1({}, key + \`__1\`, node, ctx, null); b2 = comp1({}, key + \`__1\`, node, this, null);
} }
return multi([b2]); return multi([b2]);
} }
@@ -66,7 +66,7 @@ exports[`basics a class component inside a class component, no external dom 1`]
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -106,7 +106,7 @@ exports[`basics a component inside a component 1`] = `
let block1 = createBlock(\`<span><block-child-0/></span>\`); let block1 = createBlock(\`<span><block-child-0/></span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b2 = comp1({}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -130,13 +130,16 @@ exports[`basics can be clicked on and updated 1`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><block-text-0/><button block-handler-1=\\"click\\">Inc</button></div>\`); let block3 = createBlock(\`<div><block-text-0/><button block-handler-1=\\"click\\">Inc</button></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let txt1 = ctx['state'].counter; let txt1 = ctx['state'].counter;
const v1 = ctx['state']; const v1 = ctx['state'];
let hdlr1 = [()=>v1.counter++, ctx]; let hdlr1 = [()=>v1.counter++, ctx];
return block1([txt1, hdlr1]); const b3 = block3([txt1, hdlr1]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -150,7 +153,7 @@ exports[`basics can handle empty props 1`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({val: undefined}, key + \`__1\`, node, ctx, null); const b2 = comp1({val: undefined}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -268,7 +271,7 @@ exports[`basics child can be updated 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({value: ctx['state'].counter}, key + \`__1\`, node, ctx, null); return comp1({value: ctx['state'].counter}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -305,7 +308,7 @@ exports[`basics class parent, class child component with props 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({value: 42}, key + \`__1\`, node, ctx, null); return comp1({value: 42}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -333,7 +336,7 @@ exports[`basics component children doesn't leak (if case) 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; let b2;
if (ctx['ifVar']) { if (ctx['ifVar']) {
b2 = comp1({}, key + \`__1\`, node, ctx, null); b2 = comp1({}, key + \`__1\`, node, this, null);
} }
return multi([b2]); return multi([b2]);
} }
@@ -361,7 +364,7 @@ exports[`basics component children doesn't leak (t-key case) 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const tKey_1 = ctx['keyVar']; const tKey_1 = ctx['keyVar'];
return toggler(tKey_1, comp1({}, tKey_1 + key + \`__1\`, node, ctx, null)); return toggler(tKey_1, comp1({}, tKey_1 + key + \`__1\`, node, this, null));
} }
}" }"
`; `;
@@ -427,7 +430,7 @@ exports[`basics higher order components parent and child 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({child: ctx['state'].child}, key + \`__1\`, node, ctx, null); return comp1({child: ctx['state'].child}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -442,9 +445,9 @@ exports[`basics higher order components parent and child 2`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; let b2,b3;
if (ctx['props'].child==='a') { if (ctx['props'].child==='a') {
b2 = comp1({}, key + \`__1\`, node, ctx, null); b2 = comp1({}, key + \`__1\`, node, this, null);
} else { } else {
b3 = comp2({}, key + \`__2\`, node, ctx, null); b3 = comp2({}, key + \`__2\`, node, this, null);
} }
return multi([b2, b3]); return multi([b2, b3]);
} }
@@ -485,21 +488,30 @@ exports[`basics list of two sub components inside other nodes 1`] = `
const comp1 = app.createComponent(\`SubWidget\`, true, false, false, true); const comp1 = app.createComponent(\`SubWidget\`, true, false, false, true);
const comp2 = app.createComponent(\`SubWidget\`, true, false, false, true); const comp2 = app.createComponent(\`SubWidget\`, true, false, false, true);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block3 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); <block-child-0/>
</div>\`);
let block5 = createBlock(\`<div>
<block-child-0/>
<block-child-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['state'].blips);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['state'].blips);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`blip\`] = v_block2[i1]; ctx[\`blip\`] = v_block4[i1];
const key1 = ctx['blip'].id; const key1 = ctx['blip'].id;
const b4 = comp1({}, key + \`__1__\${key1}\`, node, ctx, null); const b6 = comp1({}, key + \`__1__\${key1}\`, node, this, null);
const b5 = comp2({}, key + \`__2__\${key1}\`, node, ctx, null); const b7 = comp2({}, key + \`__2__\${key1}\`, node, this, null);
c_block2[i1] = withKey(block3([], [b4, b5]), key1); c_block4[i1] = withKey(block5([], [b6, b7]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -524,7 +536,7 @@ exports[`basics parent, child and grandchild 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -536,7 +548,7 @@ exports[`basics parent, child and grandchild 2`] = `
const comp1 = app.createComponent(\`GrandChild\`, true, false, false, true); const comp1 = app.createComponent(\`GrandChild\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -600,13 +612,21 @@ exports[`basics reconciliation alg is not confused in some specific situation 1`
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
const comp2 = app.createComponent(\`Child\`, true, false, false, true); const comp2 = app.createComponent(\`Child\`, true, false, false, true);
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
<block-child-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b2 = text(\`
\`);
const b4 = comp1({}, key + \`__1\`, node, this, null);
const tKey_1 = 4; const tKey_1 = 4;
const b3 = toggler(tKey_1, comp2({}, tKey_1 + key + \`__2\`, node, ctx, null)); const b5 = toggler(tKey_1, comp2({}, tKey_1 + key + \`__2\`, node, this, null));
return block1([], [b2, b3]); const b3 = block3([], [b4, b5]);
const b6 = text(\`
\`);
return multi([b2, b3, b6]);
} }
}" }"
`; `;
@@ -631,7 +651,7 @@ exports[`basics rerendering a widget with a sub widget 1`] = `
const comp1 = app.createComponent(\`Counter\`, true, false, false, true); const comp1 = app.createComponent(\`Counter\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -641,13 +661,16 @@ exports[`basics rerendering a widget with a sub widget 2`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><block-text-0/><button block-handler-1=\\"click\\">Inc</button></div>\`); let block3 = createBlock(\`<div><block-text-0/><button block-handler-1=\\"click\\">Inc</button></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let txt1 = ctx['state'].counter; let txt1 = ctx['state'].counter;
const v1 = ctx['state']; const v1 = ctx['state'];
let hdlr1 = [()=>v1.counter++, ctx]; let hdlr1 = [()=>v1.counter++, ctx];
return block1([txt1, hdlr1]); const b3 = block3([txt1, hdlr1]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -659,14 +682,20 @@ exports[`basics same t-keys in two different places 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
const comp2 = app.createComponent(\`Child\`, true, false, false, false); const comp2 = app.createComponent(\`Child\`, true, false, false, false);
let block1 = createBlock(\`<div><div><block-child-0/></div><div><block-child-1/></div></div>\`); let block3 = createBlock(\`<div>
<div><block-child-0/></div>
<div><block-child-1/></div>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const tKey_1 = 1; const tKey_1 = 1;
const b2 = toggler(tKey_1, comp1({blip: '1'}, tKey_1 + key + \`__1\`, node, ctx, null)); const b4 = toggler(tKey_1, comp1({blip: '1'}, tKey_1 + key + \`__1\`, node, this, null));
const tKey_2 = 1; const tKey_2 = 1;
const b3 = toggler(tKey_2, comp2({blip: '2'}, tKey_2 + key + \`__2\`, node, ctx, null)); const b5 = toggler(tKey_2, comp2({blip: '2'}, tKey_2 + key + \`__2\`, node, this, null));
return block1([], [b2, b3]); const b3 = block3([], [b4, b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -732,23 +761,30 @@ exports[`basics sub components between t-ifs 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><span><block-child-2/></span><block-child-3/></div>\`); let block3 = createBlock(\`<div>
let block2 = createBlock(\`<h1>hey</h1>\`); <block-child-0/><block-child-1/>
let block3 = createBlock(\`<h2>noo</h2>\`); <span><block-child-2/></span>
let block5 = createBlock(\`<span>test</span>\`); <block-child-3/>
</div>\`);
let block4 = createBlock(\`<h1>hey</h1>\`);
let block5 = createBlock(\`<h2>noo</h2>\`);
let block7 = createBlock(\`<span>test</span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3,b4,b5; const b2 = text(\`
\`);
let b4,b5,b6,b7;
if (ctx['state'].flag) { if (ctx['state'].flag) {
b2 = block2(); b4 = block4();
} else { } else {
b3 = block3();
}
b4 = comp1({}, key + \`__1\`, node, ctx, null);
if (ctx['state'].flag) {
b5 = block5(); b5 = block5();
} }
return block1([], [b2, b3, b4, b5]); b6 = comp1({}, key + \`__1\`, node, this, null);
if (ctx['state'].flag) {
b7 = block7();
}
const b3 = block3([], [b4, b5, b6, b7]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -772,17 +808,22 @@ exports[`basics t-elif works with t-component 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); let block3 = createBlock(\`<div>
let block2 = createBlock(\`<div>somediv</div>\`); <block-child-0/><block-child-1/>
</div>\`);
let block4 = createBlock(\`<div>somediv</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; const b2 = text(\`
\`);
let b4,b5;
if (ctx['state'].flag) { if (ctx['state'].flag) {
b2 = block2(); b4 = block4();
} else if (!ctx['state'].flag) { } else if (!ctx['state'].flag) {
b3 = comp1({}, key + \`__1\`, node, ctx, null); b5 = comp1({}, key + \`__1\`, node, this, null);
} }
return block1([], [b2, b3]); const b3 = block3([], [b4, b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -806,17 +847,22 @@ exports[`basics t-else with empty string works with t-component 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); let block3 = createBlock(\`<div>
let block2 = createBlock(\`<div>somediv</div>\`); <block-child-0/><block-child-1/>
</div>\`);
let block4 = createBlock(\`<div>somediv</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; const b2 = text(\`
\`);
let b4,b5;
if (ctx['state'].flag) { if (ctx['state'].flag) {
b2 = block2(); b4 = block4();
} else { } else {
b3 = comp1({}, key + \`__1\`, node, ctx, null); b5 = comp1({}, key + \`__1\`, node, this, null);
} }
return block1([], [b2, b3]); const b3 = block3([], [b4, b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -840,17 +886,22 @@ exports[`basics t-else works with t-component 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); let block3 = createBlock(\`<div>
let block2 = createBlock(\`<div>somediv</div>\`); <block-child-0/><block-child-1/>
</div>\`);
let block4 = createBlock(\`<div>somediv</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; const b2 = text(\`
\`);
let b4,b5;
if (ctx['state'].flag) { if (ctx['state'].flag) {
b2 = block2(); b4 = block4();
} else { } else {
b3 = comp1({}, key + \`__1\`, node, ctx, null); b5 = comp1({}, key + \`__1\`, node, this, null);
} }
return block1([], [b2, b3]); const b3 = block3([], [b4, b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -879,7 +930,7 @@ exports[`basics t-if works with t-component 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; let b2;
if (ctx['state'].flag) { if (ctx['state'].flag) {
b2 = comp1({}, key + \`__1\`, node, ctx, null); b2 = comp1({}, key + \`__1\`, node, this, null);
} }
return block1([], [b2]); return block1([], [b2]);
} }
@@ -906,16 +957,22 @@ exports[`basics t-key on a component with t-if, and a sibling component 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
const comp2 = app.createComponent(\`Child\`, true, false, false, true); const comp2 = app.createComponent(\`Child\`, true, false, false, true);
let block1 = createBlock(\`<div><block-child-0/><block-child-0/><block-child-1/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/><block-child-0/>
<block-child-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; const b2 = text(\`
\`);
let b4,b5;
if (false) { if (false) {
const tKey_1 = 'str'; const tKey_1 = 'str';
b2 = toggler(tKey_1, comp1({}, tKey_1 + key + \`__1\`, node, ctx, null)); b4 = toggler(tKey_1, comp1({}, tKey_1 + key + \`__1\`, node, this, null));
} }
b3 = comp2({}, key + \`__2\`, node, ctx, null); b5 = comp2({}, key + \`__2\`, node, this, null);
return block1([], [b2, b3]); const b3 = block3([], [b4, b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -939,15 +996,21 @@ exports[`basics text after a conditional component 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
let block1 = createBlock(\`<div><block-child-0/><span><block-text-0/></span></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
<span><block-text-0/></span>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; const b2 = text(\`
\`);
let b4;
if (ctx['state'].hasChild) { if (ctx['state'].hasChild) {
b2 = comp1({}, key + \`__1\`, node, ctx, null); b4 = comp1({}, key + \`__1\`, node, this, null);
} }
let txt1 = ctx['state'].text; let txt1 = ctx['state'].text;
return block1([txt1], [b2]); const b3 = block3([txt1], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -972,7 +1035,7 @@ exports[`basics three level of components with collapsing root nodes 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -984,7 +1047,7 @@ exports[`basics three level of components with collapsing root nodes 2`] = `
const comp1 = app.createComponent(\`GrandChild\`, true, false, false, true); const comp1 = app.createComponent(\`GrandChild\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -1010,8 +1073,8 @@ exports[`basics two child components 1`] = `
const comp2 = app.createComponent(\`Child\`, true, false, false, true); const comp2 = app.createComponent(\`Child\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b2 = comp1({}, key + \`__1\`, node, this, null);
const b3 = comp2({}, key + \`__2\`, node, ctx, null); const b3 = comp2({}, key + \`__2\`, node, this, null);
return multi([b2, b3]); return multi([b2, b3]);
} }
}" }"
@@ -1036,12 +1099,17 @@ exports[`basics update props of component without concrete own node 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, true, false); const comp1 = app.createComponent(\`Child\`, true, false, true, false);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const tKey_1 = ctx['childProps'].key; const tKey_1 = ctx['childProps'].key;
const b2 = toggler(tKey_1, comp1(Object.assign({}, ctx['childProps']), tKey_1 + key + \`__1\`, node, ctx, null)); const b4 = toggler(tKey_1, comp1(Object.assign({}, ctx['childProps']), tKey_1 + key + \`__1\`, node, this, null));
return block1([], [b2]); const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -1053,8 +1121,11 @@ exports[`basics update props of component without concrete own node 2`] = `
const comp1 = app.createComponent(\`Custom\`, true, false, false, false); const comp1 = app.createComponent(\`Custom\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const tKey_1 = ctx['props'].subKey; const tKey_1 = ctx['props'].subKey;
return toggler(tKey_1, comp1({key: ctx['props'].key,subKey: ctx['props'].subKey}, tKey_1 + key + \`__1\`, node, ctx, null)); const b3 = toggler(tKey_1, comp1({key: ctx['props'].key,subKey: ctx['props'].subKey}, tKey_1 + key + \`__1\`, node, this, null));
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -1064,12 +1135,17 @@ exports[`basics update props of component without concrete own node 3`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div class=\\"widget-subkey\\"><block-text-0/>__<block-text-1/></div>\`); let block3 = createBlock(\`<div class=\\"widget-subkey\\">
<block-text-0/>__<block-text-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let txt1 = ctx['props'].key; let txt1 = ctx['props'].key;
let txt2 = ctx['props'].subKey; let txt2 = ctx['props'].subKey;
return block1([txt1, txt2]); const b3 = block3([txt1, txt2]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -1081,14 +1157,22 @@ exports[`basics updating a component with t-foreach as root 1`] = `
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block1, v_block1, l_block1, c_block1] = prepareList(ctx['items']);; const [k_block3, v_block3, l_block3, c_block3] = prepareList(ctx['items']);;
for (let i1 = 0; i1 < l_block1; i1++) { for (let i1 = 0; i1 < l_block3; i1++) {
ctx[\`item\`] = v_block1[i1]; ctx[\`item\`] = v_block3[i1];
const key1 = ctx['item']; const key1 = ctx['item'];
c_block1[i1] = withKey(text(ctx['item']), key1); const b5 = text(\`
\`);
const b6 = text(ctx['item']);
const b7 = text(\`
\`);
c_block3[i1] = withKey(multi([b5, b6, b7]), key1);
} }
return list(c_block1); const b3 = list(c_block3);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -1100,7 +1184,7 @@ exports[`basics updating widget immediately 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({flag: ctx['state'].flag}, key + \`__1\`, node, ctx, null); return comp1({flag: ctx['state'].flag}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -1142,7 +1226,7 @@ exports[`basics widget after a t-foreach 1`] = `
} }
ctx = ctx.__proto__; ctx = ctx.__proto__;
const b2 = list(c_block2); const b2 = list(c_block2);
const b4 = comp1({}, key + \`__1\`, node, ctx, null); const b4 = comp1({}, key + \`__1\`, node, this, null);
return block1([], [b2, b4]); return block1([], [b2, b4]);
} }
}" }"
@@ -1170,7 +1254,7 @@ exports[`basics zero or one child components 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; let b2;
if (ctx['state'].hasChild) { if (ctx['state'].hasChild) {
b2 = comp1({}, key + \`__1\`, node, ctx, null); b2 = comp1({}, key + \`__1\`, node, this, null);
} }
return multi([b2]); return multi([b2]);
} }
@@ -1248,11 +1332,16 @@ exports[`support svg components add proper namespace to svg 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`GComp\`, true, false, false, true); const comp1 = app.createComponent(\`GComp\`, true, false, false, true);
let block1 = createBlock(\`<svg block-ns=\\"http://www.w3.org/2000/svg\\"><block-child-0/></svg>\`); let block3 = createBlock(\`<svg block-ns=\\"http://www.w3.org/2000/svg\\">
<block-child-0/>
</svg>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b2 = text(\`
return block1([], [b2]); \`);
const b4 = comp1({}, key + \`__1\`, node, this, null);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -1262,10 +1351,15 @@ exports[`support svg components add proper namespace to svg 2`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<g block-ns=\\"http://www.w3.org/2000/svg\\"><circle cx=\\"50\\" cy=\\"50\\" r=\\"4\\" stroke=\\"green\\" stroke-width=\\"1\\" fill=\\"yellow\\"/></g>\`); let block3 = createBlock(\`<g block-ns=\\"http://www.w3.org/2000/svg\\">
<circle cx=\\"50\\" cy=\\"50\\" r=\\"4\\" stroke=\\"green\\" stroke-width=\\"1\\" fill=\\"yellow\\"/>
</g>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return block1(); const b2 = text(\`
\`);
const b3 = block3();
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -1276,20 +1370,32 @@ exports[`t-out in components can render list of t-out 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, safeOutput, withKey } = helpers; let { prepareList, safeOutput, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['state'].items);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['state'].items);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`item\`] = v_block2[i1]; ctx[\`item\`] = v_block4[i1];
const key1 = ctx['item']; const key1 = ctx['item'];
const b4 = text(ctx['item']); const b6 = text(\`
const b5 = safeOutput(ctx['item']); \`);
c_block2[i1] = withKey(multi([b4, b5]), key1); const b7 = text(ctx['item']);
const b8 = text(\`
\`);
const b9 = safeOutput(ctx['item']);
const b10 = text(\`
\`);
c_block4[i1] = withKey(multi([b6, b7, b8, b9, b10]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -1301,9 +1407,27 @@ exports[`t-out in components can switch the contents of two t-out repeatedly 1`]
let { safeOutput } = helpers; let { safeOutput } = helpers;
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = safeOutput(ctx['state'].a); const b2 = text(\`
const b3 = safeOutput(ctx['state'].b); \`);
return multi([b2, b3]); const b3 = safeOutput(ctx['state'].a);
const b4 = text(\`
\`);
const b5 = safeOutput(ctx['state'].b);
const b6 = text(\`
\`);
return multi([b2, b3, b4, b5, b6]);
}
}"
`;
exports[`t-out in components t-out and updating falsy values, 1`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { safeOutput } = helpers;
return function template(ctx, node, key = \\"\\") {
return safeOutput(ctx['state'].a);
} }
}" }"
`; `;
@@ -8,7 +8,7 @@ exports[`Cascading renders after microtaskTick 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b2 = comp1({}, key + \`__1\`, node, this, null);
const b3 = text(\` _ \`); const b3 = text(\` _ \`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['state']);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['state']);;
@@ -31,14 +31,22 @@ exports[`Cascading renders after microtaskTick 2`] = `
const comp1 = app.createComponent(\`Element\`, true, false, false, false); const comp1 = app.createComponent(\`Element\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block1, v_block1, l_block1, c_block1] = prepareList(ctx['state']);; const [k_block3, v_block3, l_block3, c_block3] = prepareList(ctx['state']);;
for (let i1 = 0; i1 < l_block1; i1++) { for (let i1 = 0; i1 < l_block3; i1++) {
ctx[\`elem\`] = v_block1[i1]; ctx[\`elem\`] = v_block3[i1];
const key1 = ctx['elem'].id; const key1 = ctx['elem'].id;
c_block1[i1] = withKey(comp1({id: ctx['elem'].id}, key + \`__1__\${key1}\`, node, ctx, null), key1); const b5 = text(\`
\`);
const b6 = comp1({id: ctx['elem'].id}, key + \`__1__\${key1}\`, node, this, null);
const b7 = text(\`
\`);
c_block3[i1] = withKey(multi([b5, b6, b7]), key1);
} }
return list(c_block1); const b3 = list(c_block3);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -64,7 +72,7 @@ exports[`another scenario with delayed rendering 1`] = `
let b2,b3; let b2,b3;
b2 = text(\`A\`); b2 = text(\`A\`);
if (ctx['state'].value<15) { if (ctx['state'].value<15) {
b3 = comp1({value: ctx['state'].value}, key + \`__1\`, node, ctx, null); b3 = comp1({value: ctx['state'].value}, key + \`__1\`, node, this, null);
} }
return multi([b2, b3]); return multi([b2, b3]);
} }
@@ -79,7 +87,7 @@ exports[`another scenario with delayed rendering 2`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(ctx['props'].value); const b2 = text(ctx['props'].value);
const b3 = comp1({}, key + \`__1\`, node, ctx, null); const b3 = comp1({}, key + \`__1\`, node, this, null);
return multi([b2, b3]); return multi([b2, b3]);
} }
}" }"
@@ -121,7 +129,7 @@ exports[`calling render in destroy 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const tKey_1 = ctx['key']; const tKey_1 = ctx['key'];
return toggler(tKey_1, comp1({fromA: ctx['state']}, tKey_1 + key + \`__1\`, node, ctx, null)); return toggler(tKey_1, comp1({fromA: ctx['state']}, tKey_1 + key + \`__1\`, node, this, null));
} }
}" }"
`; `;
@@ -133,7 +141,7 @@ exports[`calling render in destroy 2`] = `
const comp1 = app.createComponent(\`C\`, true, false, false, false); const comp1 = app.createComponent(\`C\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({fromA: ctx['props'].fromA}, key + \`__1\`, node, ctx, null); return comp1({fromA: ctx['props'].fromA}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -143,11 +151,16 @@ exports[`calling render in destroy 3`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><block-text-0/></div>\`); let block3 = createBlock(\`<div>
<block-text-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let txt1 = ctx['props'].fromA; let txt1 = ctx['props'].fromA;
return block1([txt1]); const b3 = block3([txt1]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -177,7 +190,7 @@ exports[`changing state before first render does not trigger a render (with pare
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; let b2;
if (ctx['state'].flag) { if (ctx['state'].flag) {
b2 = comp1({}, key + \`__1\`, node, ctx, null); b2 = comp1({}, key + \`__1\`, node, this, null);
} }
return block1([], [b2]); return block1([], [b2]);
} }
@@ -221,7 +234,7 @@ exports[`concurrent renderings scenario 1 1`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, ctx, null); const b2 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -236,7 +249,7 @@ exports[`concurrent renderings scenario 1 2`] = `
let block1 = createBlock(\`<p><block-child-0/></p>\`); let block1 = createBlock(\`<p><block-child-0/></p>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({fromA: ctx['props'].fromA,fromB: ctx['state'].fromB}, key + \`__1\`, node, ctx, null); const b2 = comp1({fromA: ctx['props'].fromA,fromB: ctx['state'].fromB}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -267,7 +280,7 @@ exports[`concurrent renderings scenario 2 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let txt1 = ctx['state'].fromA; let txt1 = ctx['state'].fromA;
const b2 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, ctx, null); const b2 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, this, null);
return block1([txt1], [b2]); return block1([txt1], [b2]);
} }
}" }"
@@ -282,7 +295,7 @@ exports[`concurrent renderings scenario 2 2`] = `
let block1 = createBlock(\`<p><block-child-0/></p>\`); let block1 = createBlock(\`<p><block-child-0/></p>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({fromA: ctx['props'].fromA,fromB: ctx['state'].fromB}, key + \`__1\`, node, ctx, null); const b2 = comp1({fromA: ctx['props'].fromA,fromB: ctx['state'].fromB}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -312,7 +325,7 @@ exports[`concurrent renderings scenario 2bis 1`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, ctx, null); const b2 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -327,7 +340,7 @@ exports[`concurrent renderings scenario 2bis 2`] = `
let block1 = createBlock(\`<p><block-child-0/></p>\`); let block1 = createBlock(\`<p><block-child-0/></p>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({fromA: ctx['props'].fromA,fromB: ctx['state'].fromB}, key + \`__1\`, node, ctx, null); const b2 = comp1({fromA: ctx['props'].fromA,fromB: ctx['state'].fromB}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -357,7 +370,7 @@ exports[`concurrent renderings scenario 3 1`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, ctx, null); const b2 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -372,7 +385,7 @@ exports[`concurrent renderings scenario 3 2`] = `
let block1 = createBlock(\`<p><block-child-0/></p>\`); let block1 = createBlock(\`<p><block-child-0/></p>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({fromA: ctx['props'].fromA}, key + \`__1\`, node, ctx, null); const b2 = comp1({fromA: ctx['props'].fromA}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -387,7 +400,7 @@ exports[`concurrent renderings scenario 3 3`] = `
let block1 = createBlock(\`<span><block-child-0/></span>\`); let block1 = createBlock(\`<span><block-child-0/></span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({fromA: ctx['props'].fromA,fromC: ctx['state'].fromC}, key + \`__1\`, node, ctx, null); const b2 = comp1({fromA: ctx['props'].fromA,fromC: ctx['state'].fromC}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -417,7 +430,7 @@ exports[`concurrent renderings scenario 4 1`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, ctx, null); const b2 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -432,7 +445,7 @@ exports[`concurrent renderings scenario 4 2`] = `
let block1 = createBlock(\`<p><block-child-0/></p>\`); let block1 = createBlock(\`<p><block-child-0/></p>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({fromA: ctx['props'].fromA}, key + \`__1\`, node, ctx, null); const b2 = comp1({fromA: ctx['props'].fromA}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -447,7 +460,7 @@ exports[`concurrent renderings scenario 4 3`] = `
let block1 = createBlock(\`<span><block-child-0/></span>\`); let block1 = createBlock(\`<span><block-child-0/></span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({fromA: ctx['props'].fromA,fromC: ctx['state'].fromC}, key + \`__1\`, node, ctx, null); const b2 = comp1({fromA: ctx['props'].fromA,fromC: ctx['state'].fromC}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -477,7 +490,7 @@ exports[`concurrent renderings scenario 5 1`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, ctx, null); const b2 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -506,7 +519,7 @@ exports[`concurrent renderings scenario 6 1`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, ctx, null); const b2 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -535,7 +548,7 @@ exports[`concurrent renderings scenario 7 1`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, ctx, null); const b2 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -565,7 +578,7 @@ exports[`concurrent renderings scenario 8 1`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, ctx, null); const b2 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -593,13 +606,20 @@ exports[`concurrent renderings scenario 9 1`] = `
const comp1 = app.createComponent(\`ComponentB\`, true, false, false, false); const comp1 = app.createComponent(\`ComponentB\`, true, false, false, false);
const comp2 = app.createComponent(\`ComponentC\`, true, false, false, false); const comp2 = app.createComponent(\`ComponentC\`, true, false, false, false);
let block1 = createBlock(\`<div><block-text-0/><block-child-0/><block-child-1/></div>\`); let block3 = createBlock(\`<div>
<block-text-0/>
<block-child-0/>
<block-child-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let txt1 = ctx['state'].fromA; let txt1 = ctx['state'].fromA;
const b2 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, ctx, null); const b4 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, this, null);
const b3 = comp2({fromA: ctx['state'].fromA}, key + \`__2\`, node, ctx, null); const b5 = comp2({fromA: ctx['state'].fromA}, key + \`__2\`, node, this, null);
return block1([txt1], [b2, b3]); const b3 = block3([txt1], [b4, b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -627,7 +647,7 @@ exports[`concurrent renderings scenario 9 3`] = `
let block1 = createBlock(\`<p><block-child-0/></p>\`); let block1 = createBlock(\`<p><block-child-0/></p>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({fromA: ctx['props'].fromA,fromC: ctx['state'].fromC}, key + \`__1\`, node, ctx, null); const b2 = comp1({fromA: ctx['props'].fromA,fromC: ctx['state'].fromC}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -657,7 +677,7 @@ exports[`concurrent renderings scenario 10 1`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({value: ctx['state'].value}, key + \`__1\`, node, ctx, null); const b2 = comp1({value: ctx['state'].value}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -674,7 +694,7 @@ exports[`concurrent renderings scenario 10 2`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; let b2;
if (ctx['state'].hasChild) { if (ctx['state'].hasChild) {
b2 = comp1({value: ctx['props'].value}, key + \`__1\`, node, ctx, null); b2 = comp1({value: ctx['props'].value}, key + \`__1\`, node, this, null);
} }
return block1([], [b2]); return block1([], [b2]);
} }
@@ -704,7 +724,7 @@ exports[`concurrent renderings scenario 11 1`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({val: ctx['state'].valA}, key + \`__1\`, node, ctx, null); const b2 = comp1({val: ctx['state'].valA}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -734,7 +754,7 @@ exports[`concurrent renderings scenario 12 1`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({val: ctx['val']}, key + \`__1\`, node, ctx, null); const b2 = comp1({val: ctx['val']}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -761,15 +781,21 @@ exports[`concurrent renderings scenario 13 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
const comp2 = app.createComponent(\`Child\`, true, false, false, true); const comp2 = app.createComponent(\`Child\`, true, false, false, true);
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
<block-child-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; const b2 = text(\`
b2 = comp1({}, key + \`__1\`, node, ctx, null); \`);
let b4,b5;
b4 = comp1({}, key + \`__1\`, node, this, null);
if (ctx['state'].bool) { if (ctx['state'].bool) {
b3 = comp2({}, key + \`__2\`, node, ctx, null); b5 = comp2({}, key + \`__2\`, node, this, null);
} }
return block1([], [b2, b3]); const b3 = block3([], [b4, b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -797,7 +823,7 @@ exports[`concurrent renderings scenario 14 1`] = `
let block1 = createBlock(\`<p><block-child-0/></p>\`); let block1 = createBlock(\`<p><block-child-0/></p>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, ctx, null); const b2 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -812,7 +838,7 @@ exports[`concurrent renderings scenario 14 2`] = `
let block1 = createBlock(\`<p><block-child-0/></p>\`); let block1 = createBlock(\`<p><block-child-0/></p>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({fromB: ctx['state'].fromB,fromA: ctx['props'].fromA}, key + \`__1\`, node, ctx, null); const b2 = comp1({fromB: ctx['state'].fromB,fromA: ctx['props'].fromA}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -823,13 +849,20 @@ exports[`concurrent renderings scenario 14 3`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<p><span><block-text-0/></span><span><block-text-1/></span><span><block-text-2/></span></p>\`); let block3 = createBlock(\`<p>
<span><block-text-0/></span>
<span><block-text-1/></span>
<span><block-text-2/></span>
</p>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let txt1 = ctx['props'].fromA; let txt1 = ctx['props'].fromA;
let txt2 = ctx['props'].fromB; let txt2 = ctx['props'].fromB;
let txt3 = ctx['state'].fromC; let txt3 = ctx['state'].fromC;
return block1([txt1, txt2, txt3]); const b3 = block3([txt1, txt2, txt3]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -843,7 +876,7 @@ exports[`concurrent renderings scenario 15 1`] = `
let block1 = createBlock(\`<p><block-child-0/></p>\`); let block1 = createBlock(\`<p><block-child-0/></p>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, ctx, null); const b2 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -858,7 +891,7 @@ exports[`concurrent renderings scenario 15 2`] = `
let block1 = createBlock(\`<p><block-child-0/></p>\`); let block1 = createBlock(\`<p><block-child-0/></p>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({fromB: ctx['state'].fromB,fromA: ctx['props'].fromA}, key + \`__1\`, node, ctx, null); const b2 = comp1({fromB: ctx['state'].fromB,fromA: ctx['props'].fromA}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -869,13 +902,20 @@ exports[`concurrent renderings scenario 15 3`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<p><span><block-text-0/></span><span><block-text-1/></span><span><block-text-2/></span></p>\`); let block3 = createBlock(\`<p>
<span><block-text-0/></span>
<span><block-text-1/></span>
<span><block-text-2/></span>
</p>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let txt1 = ctx['props'].fromA; let txt1 = ctx['props'].fromA;
let txt2 = ctx['props'].fromB; let txt2 = ctx['props'].fromB;
let txt3 = ctx['state'].fromC; let txt3 = ctx['state'].fromC;
return block1([txt1, txt2, txt3]); const b3 = block3([txt1, txt2, txt3]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -887,7 +927,7 @@ exports[`concurrent renderings scenario 16 1`] = `
const comp1 = app.createComponent(\`B\`, true, false, false, false); const comp1 = app.createComponent(\`B\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, ctx, null); return comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -899,7 +939,7 @@ exports[`concurrent renderings scenario 16 2`] = `
const comp1 = app.createComponent(\`C\`, true, false, false, false); const comp1 = app.createComponent(\`C\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({fromB: ctx['state'].fromB,fromA: ctx['props'].fromA}, key + \`__1\`, node, ctx, null); return comp1({fromB: ctx['state'].fromB,fromA: ctx['props'].fromA}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -911,17 +951,20 @@ exports[`concurrent renderings scenario 16 3`] = `
const comp1 = app.createComponent(\`D\`, true, false, false, true); const comp1 = app.createComponent(\`D\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3,b4,b5,b6,b7,b8; let b2,b3,b4,b5,b6,b7,b8,b9;
b2 = text(ctx['props'].fromA); b2 = text(\`
b3 = text(\`:\`); \`);
b4 = text(ctx['props'].fromB); b3 = text(ctx['props'].fromA);
b5 = text(\`:\`); b4 = text(\`:\`);
b6 = text(ctx['state'].fromC); b5 = text(ctx['props'].fromB);
b7 = text(\`: \`); b6 = text(\`:\`);
b7 = text(ctx['state'].fromC);
b8 = text(\`:
\`);
if (ctx['state'].fromC===13) { if (ctx['state'].fromC===13) {
b8 = comp1({}, key + \`__1\`, node, ctx, null); b9 = comp1({}, key + \`__1\`, node, this, null);
} }
return multi([b2, b3, b4, b5, b6, b7, b8]); return multi([b2, b3, b4, b5, b6, b7, b8, b9]);
} }
}" }"
`; `;
@@ -945,14 +988,18 @@ exports[`creating two async components, scenario 1 1`] = `
const comp2 = app.createComponent(\`ChildB\`, true, false, false, true); const comp2 = app.createComponent(\`ChildB\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; let b2,b3,b4,b5;
b2 = text(\`
\`);
if (ctx['state'].flagA) { if (ctx['state'].flagA) {
b2 = comp1({}, key + \`__1\`, node, ctx, null); b3 = comp1({}, key + \`__1\`, node, this, null);
} }
b4 = text(\`
\`);
if (ctx['state'].flagB) { if (ctx['state'].flagB) {
b3 = comp2({}, key + \`__2\`, node, ctx, null); b5 = comp2({}, key + \`__2\`, node, this, null);
} }
return multi([b2, b3]); return multi([b2, b3, b4, b5]);
} }
}" }"
`; `;
@@ -991,15 +1038,21 @@ exports[`creating two async components, scenario 2 1`] = `
const comp1 = app.createComponent(\`ChildA\`, true, false, false, false); const comp1 = app.createComponent(\`ChildA\`, true, false, false, false);
const comp2 = app.createComponent(\`ChildB\`, true, false, false, false); const comp2 = app.createComponent(\`ChildB\`, true, false, false, false);
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
<block-child-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; const b2 = text(\`
b2 = comp1({val: ctx['state'].valA}, key + \`__1\`, node, ctx, null); \`);
let b4,b5;
b4 = comp1({val: ctx['state'].valA}, key + \`__1\`, node, this, null);
if (ctx['state'].flagB) { if (ctx['state'].flagB) {
b3 = comp2({val: ctx['state'].valB}, key + \`__2\`, node, ctx, null); b5 = comp2({val: ctx['state'].valB}, key + \`__2\`, node, this, null);
} }
return block1([], [b2, b3]); const b3 = block3([], [b4, b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -1039,15 +1092,21 @@ exports[`creating two async components, scenario 3 (patching in the same frame)
const comp1 = app.createComponent(\`ChildA\`, true, false, false, false); const comp1 = app.createComponent(\`ChildA\`, true, false, false, false);
const comp2 = app.createComponent(\`ChildB\`, true, false, false, false); const comp2 = app.createComponent(\`ChildB\`, true, false, false, false);
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
<block-child-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; const b2 = text(\`
b2 = comp1({val: ctx['state'].valA}, key + \`__1\`, node, ctx, null); \`);
let b4,b5;
b4 = comp1({val: ctx['state'].valA}, key + \`__1\`, node, this, null);
if (ctx['state'].flagB) { if (ctx['state'].flagB) {
b3 = comp2({val: ctx['state'].valB}, key + \`__2\`, node, ctx, null); b5 = comp2({val: ctx['state'].valB}, key + \`__2\`, node, this, null);
} }
return block1([], [b2, b3]); const b3 = block3([], [b4, b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -1087,7 +1146,7 @@ exports[`delay willUpdateProps 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({value: ctx['state'].value}, key + \`__1\`, node, ctx, null); return comp1({value: ctx['state'].value}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -1113,7 +1172,7 @@ exports[`delay willUpdateProps with rendering grandchild 1`] = `
const comp1 = app.createComponent(\`Parent\`, true, false, false, false); const comp1 = app.createComponent(\`Parent\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({state: ctx['state']}, key + \`__1\`, node, ctx, null); return comp1({state: ctx['state']}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -1126,8 +1185,8 @@ exports[`delay willUpdateProps with rendering grandchild 2`] = `
const comp2 = app.createComponent(\`ReactiveChild\`, true, false, false, true); const comp2 = app.createComponent(\`ReactiveChild\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({value: ctx['props'].state.value}, key + \`__1\`, node, ctx, null); const b2 = comp1({value: ctx['props'].state.value}, key + \`__1\`, node, this, null);
const b3 = comp2({}, key + \`__2\`, node, ctx, null); const b3 = comp2({}, key + \`__2\`, node, this, null);
return multi([b2, b3]); return multi([b2, b3]);
} }
}" }"
@@ -1168,7 +1227,7 @@ exports[`delayed fiber does not get rendered if it was cancelled 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`A\`); const b2 = text(\`A\`);
const b3 = comp1({}, key + \`__1\`, node, ctx, null); const b3 = comp1({}, key + \`__1\`, node, this, null);
return multi([b2, b3]); return multi([b2, b3]);
} }
}" }"
@@ -1182,7 +1241,7 @@ exports[`delayed fiber does not get rendered if it was cancelled 2`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`B\`); const b2 = text(\`B\`);
const b3 = comp1({}, key + \`__1\`, node, ctx, null); const b3 = comp1({}, key + \`__1\`, node, this, null);
return multi([b2, b3]); return multi([b2, b3]);
} }
}" }"
@@ -1196,7 +1255,7 @@ exports[`delayed fiber does not get rendered if it was cancelled 3`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`C\`); const b2 = text(\`C\`);
const b3 = comp1({}, key + \`__1\`, node, ctx, null); const b3 = comp1({}, key + \`__1\`, node, this, null);
return multi([b2, b3]); return multi([b2, b3]);
} }
}" }"
@@ -1220,7 +1279,7 @@ exports[`delayed rendering, but then initial rendering is cancelled by yet anoth
const comp1 = app.createComponent(\`B\`, true, false, false, false); const comp1 = app.createComponent(\`B\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({value: ctx['state'].value}, key + \`__1\`, node, ctx, null); return comp1({value: ctx['state'].value}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -1232,7 +1291,7 @@ exports[`delayed rendering, but then initial rendering is cancelled by yet anoth
const comp1 = app.createComponent(\`C\`, true, false, false, false); const comp1 = app.createComponent(\`C\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({value: ctx['state'].someValue+ctx['props'].value}, key + \`__1\`, node, ctx, null); return comp1({value: ctx['state'].someValue+ctx['props'].value}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -1246,7 +1305,7 @@ exports[`delayed rendering, but then initial rendering is cancelled by yet anoth
let block3 = createBlock(\`<p><block-text-0/></p>\`); let block3 = createBlock(\`<p><block-text-0/></p>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b2 = comp1({}, key + \`__1\`, node, this, null);
let txt1 = ctx['props'].value; let txt1 = ctx['props'].value;
const b3 = block3([txt1]); const b3 = block3([txt1]);
return multi([b2, b3]); return multi([b2, b3]);
@@ -1277,7 +1336,7 @@ exports[`delayed rendering, destruction, stuff happens 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`A\`); const b2 = text(\`A\`);
const b3 = comp1({value: ctx['state'].value}, key + \`__1\`, node, ctx, null); const b3 = comp1({value: ctx['state'].value}, key + \`__1\`, node, this, null);
return multi([b2, b3]); return multi([b2, b3]);
} }
}" }"
@@ -1293,7 +1352,7 @@ exports[`delayed rendering, destruction, stuff happens 2`] = `
let b2,b3; let b2,b3;
b2 = text(\`B\`); b2 = text(\`B\`);
if (ctx['state'].hasChild) { if (ctx['state'].hasChild) {
b3 = comp1({value: ctx['state'].someValue+ctx['props'].value}, key + \`__1\`, node, ctx, null); b3 = comp1({value: ctx['state'].someValue+ctx['props'].value}, key + \`__1\`, node, this, null);
} }
return multi([b2, b3]); return multi([b2, b3]);
} }
@@ -1310,7 +1369,7 @@ exports[`delayed rendering, destruction, stuff happens 3`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`C\`); const b2 = text(\`C\`);
const b3 = comp1({}, key + \`__1\`, node, ctx, null); const b3 = comp1({}, key + \`__1\`, node, this, null);
let txt1 = ctx['props'].value; let txt1 = ctx['props'].value;
const b4 = block4([txt1]); const b4 = block4([txt1]);
return multi([b2, b3, b4]); return multi([b2, b3, b4]);
@@ -1342,7 +1401,7 @@ exports[`delayed rendering, reusing fiber and stuff 1`] = `
const comp1 = app.createComponent(\`B\`, true, false, false, false); const comp1 = app.createComponent(\`B\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({value: ctx['state'].value}, key + \`__1\`, node, ctx, null); return comp1({value: ctx['state'].value}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -1355,7 +1414,7 @@ exports[`delayed rendering, reusing fiber and stuff 2`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(ctx['props'].value); const b2 = text(ctx['props'].value);
const b3 = comp1({}, key + \`__1\`, node, ctx, null); const b3 = comp1({}, key + \`__1\`, node, this, null);
return multi([b2, b3]); return multi([b2, b3]);
} }
}" }"
@@ -1386,7 +1445,7 @@ exports[`delayed rendering, reusing fiber then component is destroyed and stuff
let b2,b3; let b2,b3;
b2 = text(\`A\`); b2 = text(\`A\`);
if (ctx['state'].value<15) { if (ctx['state'].value<15) {
b3 = comp1({value: ctx['state'].value}, key + \`__1\`, node, ctx, null); b3 = comp1({value: ctx['state'].value}, key + \`__1\`, node, this, null);
} }
return multi([b2, b3]); return multi([b2, b3]);
} }
@@ -1401,7 +1460,7 @@ exports[`delayed rendering, reusing fiber then component is destroyed and stuff
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(ctx['props'].value); const b2 = text(ctx['props'].value);
const b3 = comp1({}, key + \`__1\`, node, ctx, null); const b3 = comp1({}, key + \`__1\`, node, this, null);
return multi([b2, b3]); return multi([b2, b3]);
} }
}" }"
@@ -1429,7 +1488,7 @@ exports[`delayed rendering, then component is destroyed and stuff 1`] = `
const comp1 = app.createComponent(\`B\`, true, false, false, false); const comp1 = app.createComponent(\`B\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({value: ctx['state'].value}, key + \`__1\`, node, ctx, null); return comp1({value: ctx['state'].value}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -1444,7 +1503,7 @@ exports[`delayed rendering, then component is destroyed and stuff 2`] = `
let b2,b3; let b2,b3;
b2 = text(ctx['props'].value); b2 = text(ctx['props'].value);
if (ctx['props'].value<10) { if (ctx['props'].value<10) {
b3 = comp1({}, key + \`__1\`, node, ctx, null); b3 = comp1({}, key + \`__1\`, node, this, null);
} }
return multi([b2, b3]); return multi([b2, b3]);
} }
@@ -1475,11 +1534,19 @@ exports[`destroyed component causes other soon to be destroyed component to rere
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; let b2,b3;
b2 = text(\` A \`); b2 = text(\`
A
\`);
if (ctx['state'].flag) { if (ctx['state'].flag) {
const b4 = comp1({value: ctx['state'].valueB}, key + \`__1\`, node, ctx, null); const b4 = text(\`
const b5 = comp2({value: ctx['state'].valueC}, key + \`__2\`, node, ctx, null); \`);
b3 = multi([b4, b5]); const b5 = comp1({value: ctx['state'].valueB}, key + \`__1\`, node, this, null);
const b6 = text(\`
\`);
const b7 = comp2({value: ctx['state'].valueC}, key + \`__2\`, node, this, null);
const b8 = text(\`
\`);
b3 = multi([b4, b5, b6, b7, b8]);
} }
return multi([b2, b3]); return multi([b2, b3]);
} }
@@ -1518,7 +1585,7 @@ exports[`destroying/recreating a subcomponent, other scenario 1`] = `
let b2,b3; let b2,b3;
b2 = text(\`parent\`); b2 = text(\`parent\`);
if (ctx['state'].hasChild) { if (ctx['state'].hasChild) {
b3 = comp1({}, key + \`__1\`, node, ctx, null); b3 = comp1({}, key + \`__1\`, node, this, null);
} }
return multi([b2, b3]); return multi([b2, b3]);
} }
@@ -1542,14 +1609,19 @@ exports[`destroying/recreating a subwidget with different props (if start is not
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; const b2 = text(\`
\`);
let b4;
if (ctx['state'].val>1) { if (ctx['state'].val>1) {
b2 = comp1({val: ctx['state'].val}, key + \`__1\`, node, ctx, null); b4 = comp1({val: ctx['state'].val}, key + \`__1\`, node, this, null);
} }
return block1([], [b2]); const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -1575,7 +1647,7 @@ exports[`parent and child rendered at exact same time 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({value: ctx['state'].value}, key + \`__1\`, node, ctx, null); return comp1({value: ctx['state'].value}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -1597,14 +1669,17 @@ exports[`properly behave when destroyed/unmounted while rendering 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; const b2 = text(\`
\`);
let b4;
if (ctx['state'].flag) { if (ctx['state'].flag) {
b2 = comp1({val: ctx['state'].val}, key + \`__1\`, node, ctx, null); b4 = comp1({val: ctx['state'].val}, key + \`__1\`, node, this, null);
} }
return block1([], [b2]); const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -1618,7 +1693,7 @@ exports[`properly behave when destroyed/unmounted while rendering 2`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({val: ctx['props'].val}, key + \`__1\`, node, ctx, null); const b2 = comp1({val: ctx['props'].val}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1643,15 +1718,21 @@ exports[`rendering component again in next microtick 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
let block1 = createBlock(\`<div><button block-handler-0=\\"click\\">Click</button><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<button block-handler-0=\\"click\\">Click</button>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; const b2 = text(\`
\`);
let b4;
let hdlr1 = [ctx['onClick'], ctx]; let hdlr1 = [ctx['onClick'], ctx];
if (ctx['env'].config.flag) { if (ctx['env'].config.flag) {
b2 = comp1({}, key + \`__1\`, node, ctx, null); b4 = comp1({}, key + \`__1\`, node, this, null);
} }
return block1([hdlr1], [b2]); const b3 = block3([hdlr1], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -1676,7 +1757,7 @@ exports[`rendering parent twice, with different props on child and stuff 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({value: ctx['state'].value}, key + \`__1\`, node, ctx, null); return comp1({value: ctx['state'].value}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -1701,8 +1782,8 @@ exports[`renderings, destruction, patch, stuff, ... yet another variation 1`] =
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`A\`); const b2 = text(\`A\`);
const b3 = comp1({value: ctx['state'].value}, key + \`__1\`, node, ctx, null); const b3 = comp1({value: ctx['state'].value}, key + \`__1\`, node, this, null);
const b4 = comp2({}, key + \`__2\`, node, ctx, null); const b4 = comp2({}, key + \`__2\`, node, this, null);
return multi([b2, b3, b4]); return multi([b2, b3, b4]);
} }
}" }"
@@ -1718,7 +1799,7 @@ exports[`renderings, destruction, patch, stuff, ... yet another variation 2`] =
let b2,b3; let b2,b3;
b2 = text(\`B\`); b2 = text(\`B\`);
if (ctx['props'].value===33) { if (ctx['props'].value===33) {
b3 = comp1({}, key + \`__1\`, node, ctx, null); b3 = comp1({}, key + \`__1\`, node, this, null);
} }
return multi([b2, b3]); return multi([b2, b3]);
} }
@@ -1773,12 +1854,16 @@ exports[`t-foreach with dynamic async component 1`] = `
ctx[\`arr\`] = v_block1[i1]; ctx[\`arr\`] = v_block1[i1];
ctx[\`arr_index\`] = i1; ctx[\`arr_index\`] = i1;
const key1 = ctx['arr_index']; const key1 = ctx['arr_index'];
let b3; let b3,b4,b5;
b3 = text(\`
\`);
if (ctx['arr']) { if (ctx['arr']) {
const Comp1 = ctx['myComp']; const Comp1 = ctx['myComp'];
b3 = toggler(Comp1, comp1({key: ctx['arr'][0]}, key + \`__1__\${key1}\`, node, ctx, Comp1)); b4 = toggler(Comp1, comp1({key: ctx['arr'][0]}, key + \`__1__\${key1}\`, node, this, Comp1));
} }
c_block1[i1] = withKey(multi([b3]), key1); b5 = text(\`
\`);
c_block1[i1] = withKey(multi([b3, b4, b5]), key1);
} }
return list(c_block1); return list(c_block1);
} }
@@ -1810,7 +1895,7 @@ exports[`t-key on dom node having a component 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const tKey_1 = ctx['key']; const tKey_1 = ctx['key'];
const Comp1 = ctx['myComp']; const Comp1 = ctx['myComp'];
const b2 = toggler(tKey_1, toggler(Comp1, comp1({key: ctx['key']}, tKey_1 + key + \`__1\`, node, ctx, Comp1))); const b2 = toggler(tKey_1, toggler(Comp1, comp1({key: ctx['key']}, tKey_1 + key + \`__1\`, node, this, Comp1)));
return toggler(tKey_1, block1([], [b2])); return toggler(tKey_1, block1([], [b2]));
} }
}" }"
@@ -1836,7 +1921,7 @@ exports[`t-key on dynamic async component (toggler is never patched) 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const tKey_1 = ctx['key']; const tKey_1 = ctx['key'];
const Comp1 = ctx['myComp']; const Comp1 = ctx['myComp'];
return toggler(tKey_1, toggler(Comp1, comp1({key: ctx['key']}, tKey_1 + key + \`__1\`, node, ctx, Comp1))); return toggler(tKey_1, toggler(Comp1, comp1({key: ctx['key']}, tKey_1 + key + \`__1\`, node, this, Comp1)));
} }
}" }"
`; `;
@@ -1867,7 +1952,7 @@ exports[`two renderings initiated between willPatch and patched 1`] = `
let b2; let b2;
if (ctx['state'].flag) { if (ctx['state'].flag) {
const tKey_1 = 'panel_'+ctx['state'].panel; const tKey_1 = 'panel_'+ctx['state'].panel;
b2 = toggler(tKey_1, comp1({val: ctx['state'].panel}, tKey_1 + key + \`__1\`, node, ctx, null)); b2 = toggler(tKey_1, comp1({val: ctx['state'].panel}, tKey_1 + key + \`__1\`, node, this, null));
} }
return block1([], [b2]); return block1([], [b2]);
} }
@@ -1896,7 +1981,7 @@ exports[`two sequential renderings before an animation frame 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({value: ctx['state'].value}, key + \`__1\`, node, ctx, null); return comp1({value: ctx['state'].value}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -1921,7 +2006,7 @@ exports[`update a sub-component twice in the same frame 1`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({val: ctx['state'].valA}, key + \`__1\`, node, ctx, null); const b2 = comp1({val: ctx['state'].valA}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1950,7 +2035,7 @@ exports[`update a sub-component twice in the same frame, 2 1`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({val: ctx['state'].valA}, key + \`__1\`, node, ctx, null); const b2 = comp1({val: ctx['state'].valA}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -7,7 +7,7 @@ exports[`basics display a nice error if a component is not a component 1`] = `
const comp1 = app.createComponent(\`SomeComponent\`, true, false, false, true); const comp1 = app.createComponent(\`SomeComponent\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -21,7 +21,7 @@ exports[`basics display a nice error if it cannot find component (in dev mode) 1
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {}; const props1 = {};
helpers.validateProps(\`SomeMispelledComponent\`, props1, ctx); helpers.validateProps(\`SomeMispelledComponent\`, props1, ctx);
return comp1(props1, key + \`__1\`, node, ctx, null); return comp1(props1, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -33,7 +33,7 @@ exports[`basics display a nice error if it cannot find component 1`] = `
const comp1 = app.createComponent(\`SomeMispelledComponent\`, true, false, false, true); const comp1 = app.createComponent(\`SomeMispelledComponent\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -47,7 +47,7 @@ exports[`basics no component catching error lead to full app destruction 1`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({flag: ctx['state'].flag}, key + \`__1\`, node, ctx, null); const b2 = comp1({flag: ctx['state'].flag}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -73,16 +73,26 @@ exports[`basics simple catchError 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Boom\`, true, false, false, true); const comp1 = app.createComponent(\`Boom\`, true, false, false, true);
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/><block-child-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; const b2 = text(\`
\`);
let b4,b5;
if (ctx['error']) { if (ctx['error']) {
b2 = text(\`Error\`); b4 = text(\`Error\`);
} else { } else {
b3 = comp1({}, key + \`__1\`, node, ctx, null); const b6 = text(\`
\`);
const b7 = comp1({}, key + \`__1\`, node, this, null);
const b8 = text(\`
\`);
b5 = multi([b6, b7, b8]);
} }
return block1([], [b2, b3]); const b3 = block3([], [b4, b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -108,12 +118,16 @@ exports[`can catch errors an error in onWillDestroy 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; let b2,b3,b4,b5;
b2 = text(ctx['state'].value); b2 = text(\`
\`);
b3 = text(ctx['state'].value);
b4 = text(\`
\`);
if (ctx['state'].hasChild) { if (ctx['state'].hasChild) {
b3 = comp1({}, key + \`__1\`, node, ctx, null); b5 = comp1({}, key + \`__1\`, node, this, null);
} }
return multi([b2, b3]); return multi([b2, b3, b4, b5]);
} }
}" }"
`; `;
@@ -138,12 +152,16 @@ exports[`can catch errors an error in onWillDestroy, variation 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; let b2,b3,b4,b5;
b2 = text(ctx['state'].value); b2 = text(\`
\`);
b3 = text(ctx['state'].value);
b4 = text(\`
\`);
if (ctx['state'].hasChild) { if (ctx['state'].hasChild) {
b3 = comp1({}, key + \`__1\`, node, ctx, null); b5 = comp1({}, key + \`__1\`, node, this, null);
} }
return multi([b2, b3]); return multi([b2, b3, b4, b5]);
} }
}" }"
`; `;
@@ -180,15 +198,20 @@ exports[`can catch errors can catch an error in a component render function 1`]
const comp1 = app.createComponent(\`ErrorComponent\`, true, false, false, false); const comp1 = app.createComponent(\`ErrorComponent\`, true, false, false, false);
const comp2 = app.createComponent(\`ErrorBoundary\`, true, true, false, true); const comp2 = app.createComponent(\`ErrorBoundary\`, true, true, false, true);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
function slot1(ctx, node, key = \\"\\") { function slot1(ctx, node, key = \\"\\") {
return comp1({flag: ctx['state'].flag}, key + \`__1\`, node, ctx, null); return comp1({flag: ctx['state'].flag}, key + \`__1\`, node, this, null);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b3 = comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__2\`, node, ctx, null); const b2 = text(\`
return block1([], [b3]); \`);
const b5 = comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__2\`, node, this, null);
const b3 = block3([], [b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -199,16 +222,21 @@ exports[`can catch errors can catch an error in a component render function 2`]
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { callSlot } = helpers; let { callSlot } = helpers;
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-1/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/><block-child-1/><block-child-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; const b2 = text(\`
\`);
let b4,b5;
if (ctx['state'].error) { if (ctx['state'].error) {
b2 = text(\`Error handled\`); b4 = text(\`Error handled\`);
} else { } else {
b3 = callSlot(ctx, node, key, 'default', false, {}); b5 = callSlot(ctx, node, key, 'default', false, {});
} }
return block1([], [b2, b3]); const b3 = block3([], [b4, b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -235,14 +263,16 @@ exports[`can catch errors can catch an error in the constructor call of a compon
const comp1 = app.createComponent(\`ErrorComponent\`, true, false, false, true); const comp1 = app.createComponent(\`ErrorComponent\`, true, false, false, true);
const comp2 = app.createComponent(\`ErrorBoundary\`, true, true, false, true); const comp2 = app.createComponent(\`ErrorBoundary\`, true, true, false, true);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div>
<block-child-0/>
</div>\`);
function slot1(ctx, node, key = \\"\\") { function slot1(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b3 = comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__2\`, node, ctx, null); const b3 = comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__2\`, node, this, null);
return block1([], [b3]); return block1([], [b3]);
} }
}" }"
@@ -254,7 +284,9 @@ exports[`can catch errors can catch an error in the constructor call of a compon
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { callSlot } = helpers; let { callSlot } = helpers;
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-1/></div>\`); let block1 = createBlock(\`<div>
<block-child-0/><block-child-1/><block-child-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; let b2,b3;
@@ -277,16 +309,18 @@ exports[`can catch errors can catch an error in the constructor call of a compon
const comp2 = app.createComponent(\`ErrorComponent\`, true, false, false, true); const comp2 = app.createComponent(\`ErrorComponent\`, true, false, false, true);
const comp3 = app.createComponent(\`ErrorBoundary\`, true, true, false, true); const comp3 = app.createComponent(\`ErrorBoundary\`, true, true, false, true);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div>
<block-child-0/>
</div>\`);
function slot1(ctx, node, key = \\"\\") { function slot1(ctx, node, key = \\"\\") {
const b3 = comp1({}, key + \`__1\`, node, ctx, null); const b3 = comp1({}, key + \`__1\`, node, this, null);
const b4 = comp2({}, key + \`__2\`, node, ctx, null); const b4 = comp2({}, key + \`__2\`, node, this, null);
return multi([b3, b4]); return multi([b3, b4]);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b5 = comp3({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__3\`, node, ctx, null); const b5 = comp3({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__3\`, node, this, null);
return block1([], [b5]); return block1([], [b5]);
} }
}" }"
@@ -298,7 +332,9 @@ exports[`can catch errors can catch an error in the constructor call of a compon
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { callSlot } = helpers; let { callSlot } = helpers;
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-1/></div>\`); let block1 = createBlock(\`<div>
<block-child-0/><block-child-1/><block-child-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; let b2,b3;
@@ -359,15 +395,20 @@ exports[`can catch errors can catch an error in the initial call of a component
const comp1 = app.createComponent(\`ErrorComponent\`, true, false, false, true); const comp1 = app.createComponent(\`ErrorComponent\`, true, false, false, true);
const comp2 = app.createComponent(\`ErrorBoundary\`, true, true, false, true); const comp2 = app.createComponent(\`ErrorBoundary\`, true, true, false, true);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
function slot1(ctx, node, key = \\"\\") { function slot1(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b3 = comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__2\`, node, ctx, null); const b2 = text(\`
return block1([], [b3]); \`);
const b5 = comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__2\`, node, this, null);
const b3 = block3([], [b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -378,16 +419,21 @@ exports[`can catch errors can catch an error in the initial call of a component
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { callSlot } = helpers; let { callSlot } = helpers;
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-1/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/><block-child-1/><block-child-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; const b2 = text(\`
\`);
let b4,b5;
if (ctx['state'].error) { if (ctx['state'].error) {
b2 = text(\`Error handled\`); b4 = text(\`Error handled\`);
} else { } else {
b3 = callSlot(ctx, node, key, 'default', false, {}); b5 = callSlot(ctx, node, key, 'default', false, {});
} }
return block1([], [b2, b3]); const b3 = block3([], [b4, b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -414,18 +460,23 @@ exports[`can catch errors can catch an error in the initial call of a component
const comp1 = app.createComponent(\`ErrorComponent\`, true, false, false, true); const comp1 = app.createComponent(\`ErrorComponent\`, true, false, false, true);
const comp2 = app.createComponent(\`ErrorBoundary\`, true, true, false, true); const comp2 = app.createComponent(\`ErrorBoundary\`, true, true, false, true);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
function slot1(ctx, node, key = \\"\\") { function slot1(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b3; const b2 = text(\`
\`);
let b5;
if (ctx['state'].flag) { if (ctx['state'].flag) {
b3 = comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__2\`, node, ctx, null); b5 = comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__2\`, node, this, null);
} }
return block1([], [b3]); const b3 = block3([], [b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -436,16 +487,21 @@ exports[`can catch errors can catch an error in the initial call of a component
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { callSlot } = helpers; let { callSlot } = helpers;
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-1/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/><block-child-1/><block-child-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; const b2 = text(\`
\`);
let b4,b5;
if (ctx['state'].error) { if (ctx['state'].error) {
b2 = text(\`Error handled\`); b4 = text(\`Error handled\`);
} else { } else {
b3 = callSlot(ctx, node, key, 'default', false, {}); b5 = callSlot(ctx, node, key, 'default', false, {});
} }
return block1([], [b2, b3]); const b3 = block3([], [b4, b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -471,7 +527,7 @@ exports[`can catch errors can catch an error in the mounted call (in child of ch
const comp1 = app.createComponent(\`B\`, true, false, false, true); const comp1 = app.createComponent(\`B\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -485,7 +541,7 @@ exports[`can catch errors can catch an error in the mounted call (in child of ch
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b2 = comp1({}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -497,14 +553,16 @@ exports[`can catch errors can catch an error in the mounted call (in child of ch
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Boom\`, true, false, false, true); const comp1 = app.createComponent(\`Boom\`, true, false, false, true);
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); let block1 = createBlock(\`<div>
<block-child-0/><block-child-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; let b2,b3;
if (ctx['state'].error) { if (ctx['state'].error) {
b2 = text(\`Error handled\`); b2 = text(\`Error handled\`);
} else { } else {
b3 = comp1({}, key + \`__1\`, node, ctx, null); b3 = comp1({}, key + \`__1\`, node, this, null);
} }
return block1([], [b2, b3]); return block1([], [b2, b3]);
} }
@@ -530,14 +588,16 @@ exports[`can catch errors can catch an error in the mounted call (in root compon
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`ErrorComponent\`, true, false, false, true); const comp1 = app.createComponent(\`ErrorComponent\`, true, false, false, true);
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); let block1 = createBlock(\`<div>
<block-child-0/><block-child-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; let b2,b3;
if (ctx['state'].error) { if (ctx['state'].error) {
b2 = text(\`Error handled\`); b2 = text(\`Error handled\`);
} else { } else {
b3 = comp1({}, key + \`__1\`, node, ctx, null); b3 = comp1({}, key + \`__1\`, node, this, null);
} }
return block1([], [b2, b3]); return block1([], [b2, b3]);
} }
@@ -565,14 +625,16 @@ exports[`can catch errors can catch an error in the mounted call 1`] = `
const comp1 = app.createComponent(\`ErrorComponent\`, true, false, false, true); const comp1 = app.createComponent(\`ErrorComponent\`, true, false, false, true);
const comp2 = app.createComponent(\`ErrorBoundary\`, true, true, false, true); const comp2 = app.createComponent(\`ErrorBoundary\`, true, true, false, true);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div>
<block-child-0/>
</div>\`);
function slot1(ctx, node, key = \\"\\") { function slot1(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b3 = comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__2\`, node, ctx, null); const b3 = comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__2\`, node, this, null);
return block1([], [b3]); return block1([], [b3]);
} }
}" }"
@@ -584,7 +646,9 @@ exports[`can catch errors can catch an error in the mounted call 2`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { callSlot } = helpers; let { callSlot } = helpers;
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-1/></div>\`); let block1 = createBlock(\`<div>
<block-child-0/><block-child-1/><block-child-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; let b2,b3;
@@ -619,16 +683,22 @@ exports[`can catch errors can catch an error in the willPatch call 1`] = `
const comp1 = app.createComponent(\`ErrorComponent\`, true, false, false, false); const comp1 = app.createComponent(\`ErrorComponent\`, true, false, false, false);
const comp2 = app.createComponent(\`ErrorBoundary\`, true, true, false, true); const comp2 = app.createComponent(\`ErrorBoundary\`, true, true, false, true);
let block1 = createBlock(\`<div><span><block-text-0/></span><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<span><block-text-0/></span>
<block-child-0/>
</div>\`);
function slot1(ctx, node, key = \\"\\") { function slot1(ctx, node, key = \\"\\") {
return comp1({message: ctx['state'].message}, key + \`__1\`, node, ctx, null); return comp1({message: ctx['state'].message}, key + \`__1\`, node, this, null);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let txt1 = ctx['state'].message; let txt1 = ctx['state'].message;
const b3 = comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__2\`, node, ctx, null); const b5 = comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__2\`, node, this, null);
return block1([txt1], [b3]); const b3 = block3([txt1], [b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -639,16 +709,21 @@ exports[`can catch errors can catch an error in the willPatch call 2`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { callSlot } = helpers; let { callSlot } = helpers;
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-1/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/><block-child-1/><block-child-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; const b2 = text(\`
\`);
let b4,b5;
if (ctx['state'].error) { if (ctx['state'].error) {
b2 = text(\`Error handled\`); b4 = text(\`Error handled\`);
} else { } else {
b3 = callSlot(ctx, node, key, 'default', false, {}); b5 = callSlot(ctx, node, key, 'default', false, {});
} }
return block1([], [b2, b3]); const b3 = block3([], [b4, b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -678,11 +753,11 @@ exports[`can catch errors can catch an error in the willStart call 1`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
function slot1(ctx, node, key = \\"\\") { function slot1(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b3 = comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__2\`, node, ctx, null); const b3 = comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__2\`, node, this, null);
return block1([], [b3]); return block1([], [b3]);
} }
}" }"
@@ -694,16 +769,21 @@ exports[`can catch errors can catch an error in the willStart call 2`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { callSlot } = helpers; let { callSlot } = helpers;
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-1/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/><block-child-1/><block-child-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; const b2 = text(\`
\`);
let b4,b5;
if (ctx['state'].error) { if (ctx['state'].error) {
b2 = text(\`Error handled\`); b4 = text(\`Error handled\`);
} else { } else {
b3 = callSlot(ctx, node, key, 'default', false, {}); b5 = callSlot(ctx, node, key, 'default', false, {});
} }
return block1([], [b2, b3]); const b3 = block3([], [b4, b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -730,16 +810,18 @@ exports[`can catch errors can catch an error origination from a child's willStar
const comp2 = app.createComponent(\`ErrorComponent\`, true, false, false, true); const comp2 = app.createComponent(\`ErrorComponent\`, true, false, false, true);
const comp3 = app.createComponent(\`ErrorBoundary\`, true, true, false, true); const comp3 = app.createComponent(\`ErrorBoundary\`, true, true, false, true);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div>
<block-child-0/>
</div>\`);
function slot1(ctx, node, key = \\"\\") { function slot1(ctx, node, key = \\"\\") {
const b3 = comp1({}, key + \`__1\`, node, ctx, null); const b3 = comp1({}, key + \`__1\`, node, this, null);
const b4 = comp2({}, key + \`__2\`, node, ctx, null); const b4 = comp2({}, key + \`__2\`, node, this, null);
return multi([b3, b4]); return multi([b3, b4]);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b5 = comp3({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__3\`, node, ctx, null); const b5 = comp3({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__3\`, node, this, null);
return block1([], [b5]); return block1([], [b5]);
} }
}" }"
@@ -751,7 +833,9 @@ exports[`can catch errors can catch an error origination from a child's willStar
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { callSlot } = helpers; let { callSlot } = helpers;
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-1/></div>\`); let block1 = createBlock(\`<div>
<block-child-0/><block-child-1/><block-child-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; let b2,b3;
@@ -797,16 +881,26 @@ exports[`can catch errors catchError in catchError 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/><block-child-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; const b2 = text(\`
\`);
let b4,b5;
if (ctx['error']) { if (ctx['error']) {
b2 = text(\`Error\`); b4 = text(\`Error\`);
} else { } else {
b3 = comp1({}, key + \`__1\`, node, ctx, null); const b6 = text(\`
\`);
const b7 = comp1({}, key + \`__1\`, node, this, null);
const b8 = text(\`
\`);
b5 = multi([b6, b7, b8]);
} }
return block1([], [b2, b3]); const b3 = block3([], [b4, b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -817,11 +911,16 @@ exports[`can catch errors catchError in catchError 2`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Boom\`, true, false, false, true); const comp1 = app.createComponent(\`Boom\`, true, false, false, true);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b2 = text(\`
return block1([], [b2]); \`);
const b4 = comp1({}, key + \`__1\`, node, this, null);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -849,21 +948,34 @@ exports[`can catch errors catching error, rethrow, render parent -- a main comp
const comp2 = app.createComponent(\`ErrorHandler\`, true, true, false, false); const comp2 = app.createComponent(\`ErrorHandler\`, true, true, false, false);
function slot1(ctx, node, key = \\"\\") { function slot1(ctx, node, key = \\"\\") {
const b7 = text(\`
\`);
const Comp1 = ctx['cp'].Comp; const Comp1 = ctx['cp'].Comp;
return toggler(Comp1, comp1({}, key + \`__1\`, node, ctx, Comp1)); const b8 = toggler(Comp1, comp1({}, key + \`__1\`, node, this, Comp1));
const b9 = text(\`
\`);
return multi([b7, b8, b9]);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block1, v_block1, l_block1, c_block1] = prepareList(Object.values(ctx['state'].cps));; const [k_block3, v_block3, l_block3, c_block3] = prepareList(Object.values(ctx['state'].cps));;
for (let i1 = 0; i1 < l_block1; i1++) { for (let i1 = 0; i1 < l_block3; i1++) {
ctx[\`cp\`] = v_block1[i1]; ctx[\`cp\`] = v_block3[i1];
const key1 = ctx['cp'].id; const key1 = ctx['cp'].id;
const b5 = text(\`
\`);
const v1 = ctx['cp']; const v1 = ctx['cp'];
const ctx1 = capture(ctx); const ctx1 = capture(ctx);
c_block1[i1] = withKey(comp2({onError: ()=>this.cleanUp(v1.id),slots: markRaw({'default': {__render: slot1, __ctx: ctx1}})}, key + \`__2__\${key1}\`, node, ctx, null), key1); const b10 = comp2({onError: ()=>this.cleanUp(v1.id),slots: markRaw({'default': {__render: slot1, __ctx: ctx1}})}, key + \`__2__\${key1}\`, node, this, null);
const b11 = text(\`
\`);
c_block3[i1] = withKey(multi([b5, b10, b11]), key1);
} }
return list(c_block1); const b3 = list(c_block3);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -887,7 +999,7 @@ exports[`can catch errors catching error, rethrow, render parent -- a main comp
const comp1 = app.createComponent(\`ErrorComponent\`, true, false, false, true); const comp1 = app.createComponent(\`ErrorComponent\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -927,21 +1039,37 @@ exports[`can catch errors catching in child makes parent render 1`] = `
const comp2 = app.createComponent(\`Catch\`, true, true, false, false); const comp2 = app.createComponent(\`Catch\`, true, true, false, false);
function slot1(ctx, node, key = \\"\\") { function slot1(ctx, node, key = \\"\\") {
const b7 = text(\`
\`);
const Comp1 = ctx['elem'][1]; const Comp1 = ctx['elem'][1];
return toggler(Comp1, comp1({id: ctx['elem'][0]}, key + \`__1\`, node, ctx, Comp1)); const b8 = toggler(Comp1, comp1({id: ctx['elem'][0]}, key + \`__1\`, node, this, Comp1));
const b9 = text(\`
\`);
return multi([b7, b8, b9]);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block1, v_block1, l_block1, c_block1] = prepareList(Object.entries(this.elements));; const [k_block3, v_block3, l_block3, c_block3] = prepareList(Object.entries(this.elements));;
for (let i1 = 0; i1 < l_block1; i1++) { for (let i1 = 0; i1 < l_block3; i1++) {
ctx[\`elem\`] = v_block1[i1]; ctx[\`elem\`] = v_block3[i1];
const key1 = ctx['elem'][0]; const key1 = ctx['elem'][0];
const b5 = text(\`
\`);
const v1 = ctx['elem']; const v1 = ctx['elem'];
const ctx1 = capture(ctx); const ctx1 = capture(ctx);
c_block1[i1] = withKey(comp2({onError: (_error)=>this.onError(v1[0],_error),slots: markRaw({'default': {__render: slot1, __ctx: ctx1}})}, key + \`__2__\${key1}\`, node, ctx, null), key1); const b10 = comp2({onError: (_error)=>this.onError(v1[0],_error),slots: markRaw({'default': {__render: slot1, __ctx: ctx1}})}, key + \`__2__\${key1}\`, node, this, null);
const b11 = text(\`
\`);
c_block3[i1] = withKey(multi([b5, b10, b11]), key1);
} }
return list(c_block1); ctx = ctx.__proto__;
const b3 = list(c_block3);
const b12 = text(\`
\`);
return multi([b2, b3, b12]);
} }
}" }"
`; `;
@@ -994,15 +1122,18 @@ exports[`can catch errors error in mounted on a component with a sibling (proper
const comp2 = app.createComponent(\`ErrorComponent\`, true, false, false, true); const comp2 = app.createComponent(\`ErrorComponent\`, true, false, false, true);
const comp3 = app.createComponent(\`ErrorBoundary\`, true, true, false, true); const comp3 = app.createComponent(\`ErrorBoundary\`, true, true, false, true);
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); let block1 = createBlock(\`<div>
<block-child-0/>
<block-child-1/>
</div>\`);
function slot1(ctx, node, key = \\"\\") { function slot1(ctx, node, key = \\"\\") {
return comp2({}, key + \`__2\`, node, ctx, null); return comp2({}, key + \`__2\`, node, this, null);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b2 = comp1({}, key + \`__1\`, node, this, null);
const b4 = comp3({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__3\`, node, ctx, null); const b4 = comp3({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__3\`, node, this, null);
return block1([], [b2, b4]); return block1([], [b2, b4]);
} }
}" }"
@@ -1025,7 +1156,9 @@ exports[`can catch errors error in mounted on a component with a sibling (proper
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { callSlot } = helpers; let { callSlot } = helpers;
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-1/></div>\`); let block1 = createBlock(\`<div>
<block-child-0/><block-child-1/><block-child-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; let b2,b3;
@@ -1059,7 +1192,7 @@ exports[`can catch errors onError in class inheritance is called if rethrown 1`]
const comp1 = app.createComponent(\`Concrete\`, true, false, false, true); const comp1 = app.createComponent(\`Concrete\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -1069,16 +1202,28 @@ exports[`can catch errors onError in class inheritance is called if rethrown 2`]
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); let block1 = createBlock(\`<div>
<block-child-0/><block-child-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; let b2,b6;
if (!ctx['state'].error) { if (!ctx['state'].error) {
b2 = text(this.will.crash); const b3 = text(\`
\`);
const b4 = text(this.will.crash);
const b5 = text(\`
\`);
b2 = multi([b3, b4, b5]);
} else { } else {
b3 = text(ctx['state'].error); const b7 = text(\`
\`);
const b8 = text(ctx['state'].error);
const b9 = text(\`
\`);
b6 = multi([b7, b8, b9]);
} }
return block1([], [b2, b3]); return block1([], [b2, b6]);
} }
}" }"
`; `;
@@ -1090,7 +1235,7 @@ exports[`can catch errors onError in class inheritance is not called if no rethr
const comp1 = app.createComponent(\`Concrete\`, true, false, false, true); const comp1 = app.createComponent(\`Concrete\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -1100,16 +1245,28 @@ exports[`can catch errors onError in class inheritance is not called if no rethr
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); let block1 = createBlock(\`<div>
<block-child-0/><block-child-1/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; let b2,b6;
if (!ctx['state'].error) { if (!ctx['state'].error) {
b2 = text(this.will.crash); const b3 = text(\`
\`);
const b4 = text(this.will.crash);
const b5 = text(\`
\`);
b2 = multi([b3, b4, b5]);
} else { } else {
b3 = text(ctx['state'].error); const b7 = text(\`
\`);
const b8 = text(ctx['state'].error);
const b9 = text(\`
\`);
b6 = multi([b7, b8, b9]);
} }
return block1([], [b2, b3]); return block1([], [b2, b6]);
} }
}" }"
`; `;
@@ -1123,7 +1280,7 @@ exports[`errors and promises a rendering error in a sub component will reject th
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b2 = comp1({}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1166,7 +1323,7 @@ exports[`errors and promises a rendering error will reject the render promise (w
let block1 = createBlock(\`<div><block-child-0/><block-text-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/><block-text-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b2 = comp1({}, key + \`__1\`, node, this, null);
let txt1 = ctx['x'].y; let txt1 = ctx['x'].y;
return block1([txt1], [b2]); return block1([txt1], [b2]);
} }
@@ -38,7 +38,7 @@ exports[`event handling handler receive the event as argument 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let hdlr1 = [ctx['inc'], ctx]; let hdlr1 = [ctx['inc'], ctx];
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b2 = comp1({}, key + \`__1\`, node, this, null);
let txt1 = ctx['state'].value; let txt1 = ctx['state'].value;
return block1([hdlr1, txt1], [b2]); return block1([hdlr1, txt1], [b2]);
} }
@@ -64,14 +64,20 @@ exports[`event handling input blur event is not called if component is destroyed
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
let block1 = createBlock(\`<div><block-child-0/><textarea/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
<textarea/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; const b2 = text(\`
\`);
let b4;
if (ctx['state'].cond) { if (ctx['state'].cond) {
b2 = comp1({}, key + \`__1\`, node, ctx, null); b4 = comp1({}, key + \`__1\`, node, this, null);
} }
return block1([], [b2]); const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -96,22 +102,33 @@ exports[`event handling objects from scope are properly captured by t-on 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block3 = createBlock(\`<div class=\\"item\\" block-handler-0=\\"click\\"/>\`); <block-child-0/>
</div>\`);
let block7 = createBlock(\`<div class=\\"item\\" block-handler-0=\\"click\\"/>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['items']);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['items']);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`item\`] = v_block2[i1]; ctx[\`item\`] = v_block4[i1];
const key1 = ctx['item']; const key1 = ctx['item'];
const b6 = text(\`
\`);
const v1 = ctx['onClick']; const v1 = ctx['onClick'];
const v2 = ctx['item']; const v2 = ctx['item'];
let hdlr1 = [_ev=>v1(v2.val,_ev), ctx]; let hdlr1 = [_ev=>v1(v2.val,_ev), ctx];
c_block2[i1] = withKey(block3([hdlr1]), key1); const b7 = block7([hdlr1]);
const b8 = text(\`
\`);
c_block4[i1] = withKey(multi([b6, b7, b8]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -121,12 +138,15 @@ exports[`event handling support for callable expression in event handler 1`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><block-text-0/><input type=\\"text\\" block-handler-1=\\"input\\"/></div>\`); let block3 = createBlock(\`<div><block-text-0/><input type=\\"text\\" block-handler-1=\\"input\\"/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let txt1 = ctx['state'].value; let txt1 = ctx['state'].value;
let hdlr1 = [ctx['obj'].onInput, ctx]; let hdlr1 = [ctx['obj'].onInput, ctx];
return block1([txt1, hdlr1]); const b3 = block3([txt1, hdlr1]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -137,22 +157,33 @@ exports[`event handling t-on with handler bound to dynamic argument on a t-forea
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block3 = createBlock(\`<div class=\\"item\\" block-handler-0=\\"click\\"/>\`); <block-child-0/>
</div>\`);
let block7 = createBlock(\`<div class=\\"item\\" block-handler-0=\\"click\\"/>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['items']);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['items']);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`item\`] = v_block2[i1]; ctx[\`item\`] = v_block4[i1];
const key1 = ctx['item']; const key1 = ctx['item'];
const b6 = text(\`
\`);
const v1 = ctx['onClick']; const v1 = ctx['onClick'];
const v2 = ctx['item']; const v2 = ctx['item'];
let hdlr1 = [_ev=>v1(v2,_ev), ctx]; let hdlr1 = [_ev=>v1(v2,_ev), ctx];
c_block2[i1] = withKey(block3([hdlr1]), key1); const b7 = block7([hdlr1]);
const b8 = text(\`
\`);
c_block4[i1] = withKey(multi([b6, b7, b8]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -7,7 +7,7 @@ exports[`basics basic use 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({p: 1}, key + \`__1\`, node, ctx, null); return comp1({p: 1}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -34,14 +34,24 @@ exports[`basics can select a sub widget 1`] = `
const comp2 = app.createComponent(\`OtherChild\`, true, false, false, true); const comp2 = app.createComponent(\`OtherChild\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; let b2,b3,b4,b5,b6,b7,b8;
b2 = text(\`
\`);
b3 = text(\`
\`);
if (ctx['env'].options.flag) { if (ctx['env'].options.flag) {
b2 = comp1({}, key + \`__1\`, node, ctx, null); b4 = comp1({}, key + \`__1\`, node, this, null);
} }
b5 = text(\`
\`);
if (!ctx['env'].options.flag) { if (!ctx['env'].options.flag) {
b3 = comp2({}, key + \`__2\`, node, ctx, null); b6 = comp2({}, key + \`__2\`, node, this, null);
} }
return multi([b2, b3]); b7 = text(\`
\`);
b8 = text(\`
\`);
return multi([b2, b3, b4, b5, b6, b7, b8]);
} }
}" }"
`; `;
@@ -80,14 +90,24 @@ exports[`basics can select a sub widget, part 2 1`] = `
const comp2 = app.createComponent(\`OtherChild\`, true, false, false, true); const comp2 = app.createComponent(\`OtherChild\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; let b2,b3,b4,b5,b6,b7,b8;
b2 = text(\`
\`);
b3 = text(\`
\`);
if (ctx['state'].flag) { if (ctx['state'].flag) {
b2 = comp1({}, key + \`__1\`, node, ctx, null); b4 = comp1({}, key + \`__1\`, node, this, null);
} }
b5 = text(\`
\`);
if (!ctx['state'].flag) { if (!ctx['state'].flag) {
b3 = comp2({}, key + \`__2\`, node, ctx, null); b6 = comp2({}, key + \`__2\`, node, this, null);
} }
return multi([b2, b3]); b7 = text(\`
\`);
b8 = text(\`
\`);
return multi([b2, b3, b4, b5, b6, b7, b8]);
} }
}" }"
`; `;
@@ -125,7 +145,7 @@ exports[`basics sub widget is interactive 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({p: 1}, key + \`__1\`, node, ctx, null); return comp1({p: 1}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -135,12 +155,17 @@ exports[`basics sub widget is interactive 2`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<span><button block-handler-0=\\"click\\">click</button>child<block-text-1/></span>\`); let block3 = createBlock(\`<span>
<button block-handler-0=\\"click\\">click</button>child<block-text-1/>
</span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let hdlr1 = [ctx['inc'], ctx]; let hdlr1 = [ctx['inc'], ctx];
let txt1 = ctx['state'].val; let txt1 = ctx['state'].val;
return block1([hdlr1, txt1]); const b3 = block3([hdlr1, txt1]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -154,7 +179,7 @@ exports[`basics top level sub widget with a parent 1`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b2 = comp1({}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -167,7 +192,7 @@ exports[`basics top level sub widget with a parent 2`] = `
const comp1 = app.createComponent(\`ComponentC\`, true, false, false, true); const comp1 = app.createComponent(\`ComponentC\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -5,18 +5,24 @@ exports[`hooks autofocus hook input in a t-if 1`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><input block-ref=\\"0\\"/><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block2 = createBlock(\`<input block-ref=\\"0\\"/>\`); <input block-ref=\\"0\\"/>
<block-child-0/>
</div>\`);
let block4 = createBlock(\`<input block-ref=\\"0\\"/>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const refs = ctx.__owl__.refs; const refs = ctx.__owl__.refs;
const ref1 = (el) => refs[\`input1\`] = el; const ref1 = (el) => refs[\`input1\`] = el;
const ref2 = (el) => refs[\`input2\`] = el; const ref2 = (el) => refs[\`input2\`] = el;
let b2; const b2 = text(\`
\`);
let b4;
if (ctx['state'].flag) { if (ctx['state'].flag) {
b2 = block2([ref2]); b4 = block4([ref2]);
} }
return block1([ref1], [b2]); const b3 = block3([ref1], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -26,13 +32,19 @@ exports[`hooks autofocus hook simple input 1`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><input block-ref=\\"0\\"/><input block-ref=\\"1\\"/></div>\`); let block3 = createBlock(\`<div>
<input block-ref=\\"0\\"/>
<input block-ref=\\"1\\"/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const refs = ctx.__owl__.refs; const refs = ctx.__owl__.refs;
const ref1 = (el) => refs[\`input1\`] = el; const ref1 = (el) => refs[\`input1\`] = el;
const ref2 = (el) => refs[\`input2\`] = el; const ref2 = (el) => refs[\`input2\`] = el;
return block1([ref1, ref2]); const b2 = text(\`
\`);
const b3 = block3([ref1, ref2]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -44,7 +56,7 @@ exports[`hooks can use onWillStart, onWillUpdateProps 1`] = `
const comp1 = app.createComponent(\`MyComponent\`, true, false, false, false); const comp1 = app.createComponent(\`MyComponent\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({value: ctx['state'].value}, key + \`__1\`, node, ctx, null); return comp1({value: ctx['state'].value}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -112,7 +124,7 @@ exports[`hooks parent and child env (with useChildSubEnv then useSubEnv) 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(ctx['env'].val); const b2 = text(ctx['env'].val);
const b3 = comp1({}, key + \`__1\`, node, ctx, null); const b3 = comp1({}, key + \`__1\`, node, this, null);
return multi([b2, b3]); return multi([b2, b3]);
} }
}" }"
@@ -144,7 +156,7 @@ exports[`hooks parent and child env (with useChildSubEnv) 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(ctx['env'].val); const b2 = text(ctx['env'].val);
const b3 = comp1({}, key + \`__1\`, node, ctx, null); const b3 = comp1({}, key + \`__1\`, node, this, null);
return multi([b2, b3]); return multi([b2, b3]);
} }
}" }"
@@ -172,7 +184,7 @@ exports[`hooks parent and child env (with useSubEnv) 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(ctx['env'].val); const b2 = text(ctx['env'].val);
const b3 = comp1({}, key + \`__1\`, node, ctx, null); const b3 = comp1({}, key + \`__1\`, node, this, null);
return multi([b2, b3]); return multi([b2, b3]);
} }
}" }"
@@ -227,7 +239,7 @@ exports[`hooks useChildSubEnv supports arbitrary descriptor 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -265,16 +277,23 @@ exports[`hooks useEffect hook effect can depend on stuff in dom 1`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block2 = createBlock(\`<div block-ref=\\"0\\"/>\`); let block5 = createBlock(\`<div block-ref=\\"0\\"/>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const refs = ctx.__owl__.refs; const refs = ctx.__owl__.refs;
const ref1 = (el) => refs[\`div\`] = el; const ref1 = (el) => refs[\`div\`] = el;
let b2; let b2,b3;
b2 = text(\`
\`);
if (ctx['state'].value) { if (ctx['state'].value) {
b2 = block2([ref1]); const b4 = text(\`
\`);
const b5 = block5([ref1]);
const b6 = text(\`
\`);
b3 = multi([b4, b5, b6]);
} }
return multi([b2]); return multi([b2, b3]);
} }
}" }"
`; `;
@@ -328,7 +347,7 @@ exports[`hooks useExternalListener 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; let b2;
if (ctx['state'].flag) { if (ctx['state'].flag) {
b2 = comp1({}, key + \`__1\`, node, ctx, null); b2 = comp1({}, key + \`__1\`, node, this, null);
} }
return multi([b2]); return multi([b2]);
} }
@@ -386,7 +405,7 @@ exports[`hooks useSubEnv supports arbitrary descriptor 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -23,8 +23,8 @@ exports[`lifecycle hooks component semantics 1`] = `
let block1 = createBlock(\`<div>A<block-child-0/><block-child-1/></div>\`); let block1 = createBlock(\`<div>A<block-child-0/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b2 = comp1({}, key + \`__1\`, node, this, null);
const b3 = comp2({}, key + \`__2\`, node, ctx, null); const b3 = comp2({}, key + \`__2\`, node, this, null);
return block1([], [b2, b3]); return block1([], [b2, b3]);
} }
}" }"
@@ -51,17 +51,22 @@ exports[`lifecycle hooks component semantics 3`] = `
const comp2 = app.createComponent(\`E\`, true, false, false, true); const comp2 = app.createComponent(\`E\`, true, false, false, true);
const comp3 = app.createComponent(\`F\`, true, false, false, true); const comp3 = app.createComponent(\`F\`, true, false, false, true);
let block1 = createBlock(\`<div>C<block-child-0/><block-child-1/><block-child-2/></div>\`); let block3 = createBlock(\`<div>C<block-child-0/>
<block-child-1/><block-child-2/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3,b4; const b2 = text(\`
b2 = comp1({}, key + \`__1\`, node, ctx, null); \`);
let b4,b5,b6;
b4 = comp1({}, key + \`__1\`, node, this, null);
if (ctx['state'].flag) { if (ctx['state'].flag) {
b3 = comp2({}, key + \`__2\`, node, ctx, null); b5 = comp2({}, key + \`__2\`, node, this, null);
} else { } else {
b4 = comp3({}, key + \`__3\`, node, ctx, null); b6 = comp3({}, key + \`__3\`, node, this, null);
} }
return block1([], [b2, b3, b4]); const b3 = block3([], [b4, b5, b6]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -111,15 +116,21 @@ exports[`lifecycle hooks components are unmounted and destroyed if no longer in
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
let block2 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; let b2,b3,b5;
b2 = text(\`
\`);
if (ctx['state'].flag) { if (ctx['state'].flag) {
const b3 = comp1({n: ctx['state'].n}, key + \`__1\`, node, ctx, null); const b4 = comp1({n: ctx['state'].n}, key + \`__1\`, node, this, null);
b2 = block2([], [b3]); b3 = block3([], [b4]);
} }
return multi([b2]); b5 = text(\`
\`);
return multi([b2, b3, b5]);
} }
}" }"
`; `;
@@ -147,7 +158,7 @@ exports[`lifecycle hooks components are unmounted destroyed if no longer in DOM
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; let b2;
if (ctx['state'].ok) { if (ctx['state'].ok) {
b2 = comp1({}, key + \`__1\`, node, ctx, null); b2 = comp1({}, key + \`__1\`, node, this, null);
} }
return multi([b2]); return multi([b2]);
} }
@@ -177,7 +188,7 @@ exports[`lifecycle hooks destroy new children before being mountged 1`] = `
let b2,b3,b4; let b2,b3,b4;
b2 = text(\`before\`); b2 = text(\`before\`);
if (ctx['state'].flag) { if (ctx['state'].flag) {
b3 = comp1({}, key + \`__1\`, node, ctx, null); b3 = comp1({}, key + \`__1\`, node, this, null);
} }
b4 = text(\`after\`); b4 = text(\`after\`);
return multi([b2, b3, b4]); return multi([b2, b3, b4]);
@@ -205,7 +216,7 @@ exports[`lifecycle hooks hooks are called in proper order in widget creation/des
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b2 = comp1({}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -231,7 +242,7 @@ exports[`lifecycle hooks lifecycle callbacks are bound to component 1`] = `
const comp1 = app.createComponent(\`Test\`, true, false, false, false); const comp1 = app.createComponent(\`Test\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({rev: ctx['rev']}, key + \`__1\`, node, ctx, null); return comp1({rev: ctx['rev']}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -256,7 +267,7 @@ exports[`lifecycle hooks lifecycle semantics 1`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({a: ctx['state'].a}, key + \`__1\`, node, ctx, null); const b2 = comp1({a: ctx['state'].a}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -284,7 +295,7 @@ exports[`lifecycle hooks lifecycle semantics, part 2 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; let b2;
if (ctx['state'].hasChild) { if (ctx['state'].hasChild) {
b2 = comp1({}, key + \`__1\`, node, ctx, null); b2 = comp1({}, key + \`__1\`, node, this, null);
} }
return multi([b2]); return multi([b2]);
} }
@@ -298,7 +309,7 @@ exports[`lifecycle hooks lifecycle semantics, part 2 2`] = `
const comp1 = app.createComponent(\`GrandChild\`, true, false, false, true); const comp1 = app.createComponent(\`GrandChild\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -325,7 +336,7 @@ exports[`lifecycle hooks lifecycle semantics, part 3 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; let b2;
if (ctx['state'].hasChild) { if (ctx['state'].hasChild) {
b2 = comp1({}, key + \`__1\`, node, ctx, null); b2 = comp1({}, key + \`__1\`, node, this, null);
} }
return multi([b2]); return multi([b2]);
} }
@@ -341,7 +352,7 @@ exports[`lifecycle hooks lifecycle semantics, part 4 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; let b2;
if (ctx['state'].hasChild) { if (ctx['state'].hasChild) {
b2 = comp1({}, key + \`__1\`, node, ctx, null); b2 = comp1({}, key + \`__1\`, node, this, null);
} }
return multi([b2]); return multi([b2]);
} }
@@ -355,7 +366,7 @@ exports[`lifecycle hooks lifecycle semantics, part 4 2`] = `
const comp1 = app.createComponent(\`GrandChild\`, true, false, false, true); const comp1 = app.createComponent(\`GrandChild\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -382,7 +393,7 @@ exports[`lifecycle hooks lifecycle semantics, part 5 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; let b2;
if (ctx['state'].hasChild) { if (ctx['state'].hasChild) {
b2 = comp1({}, key + \`__1\`, node, ctx, null); b2 = comp1({}, key + \`__1\`, node, this, null);
} }
return multi([b2]); return multi([b2]);
} }
@@ -409,7 +420,7 @@ exports[`lifecycle hooks lifecycle semantics, part 6 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({value: ctx['state'].value}, key + \`__1\`, node, ctx, null); return comp1({value: ctx['state'].value}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -449,7 +460,7 @@ exports[`lifecycle hooks mounted hook is called on every mount, not just the fir
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; let b2;
if (ctx['state'].hasChild) { if (ctx['state'].hasChild) {
b2 = comp1({}, key + \`__1\`, node, ctx, null); b2 = comp1({}, key + \`__1\`, node, this, null);
} }
return multi([b2]); return multi([b2]);
} }
@@ -478,7 +489,7 @@ exports[`lifecycle hooks mounted hook is called on subcomponents, in proper orde
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b2 = comp1({}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -508,7 +519,7 @@ exports[`lifecycle hooks mounted hook is called on subsubcomponents, in proper o
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; let b2;
if (ctx['state'].flag) { if (ctx['state'].flag) {
b2 = comp1({}, key + \`__1\`, node, ctx, null); b2 = comp1({}, key + \`__1\`, node, this, null);
} }
return block1([], [b2]); return block1([], [b2]);
} }
@@ -524,7 +535,7 @@ exports[`lifecycle hooks mounted hook is called on subsubcomponents, in proper o
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b2 = comp1({}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -550,7 +561,10 @@ exports[`lifecycle hooks onWillRender 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({someValue: ctx['state'].value}, key + \`__1\`, node, ctx, null); const b2 = text(\`
\`);
const b3 = comp1({someValue: ctx['state'].value}, key + \`__1\`, node, this, null);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -579,7 +593,7 @@ exports[`lifecycle hooks patched hook is called after updateProps 1`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({a: ctx['state'].a}, key + \`__1\`, node, ctx, null); const b2 = comp1({a: ctx['state'].a}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -663,7 +677,7 @@ exports[`lifecycle hooks sub widget (inside sub node): hooks are correctly calle
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; let b2;
if (ctx['state'].flag) { if (ctx['state'].flag) {
b2 = comp1({}, key + \`__1\`, node, ctx, null); b2 = comp1({}, key + \`__1\`, node, this, null);
} }
return multi([b2]); return multi([b2]);
} }
@@ -705,7 +719,7 @@ exports[`lifecycle hooks timeout in onWillUpdateProps emits a warning 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {prop: ctx['state'].prop}; const props1 = {prop: ctx['state'].prop};
helpers.validateProps(\`Child\`, props1, ctx); helpers.validateProps(\`Child\`, props1, ctx);
return comp1(props1, key + \`__1\`, node, ctx, null); return comp1(props1, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -727,11 +741,16 @@ exports[`lifecycle hooks willPatch, patched hook are called on subsubcomponents,
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({n: ctx['state'].n}, key + \`__1\`, node, ctx, null); const b2 = text(\`
return block1([], [b2]); \`);
const b4 = comp1({n: ctx['state'].n}, key + \`__1\`, node, this, null);
const b3 = block3([], [b4]);
const b5 = text(\`
\`);
return multi([b2, b3, b5]);
} }
}" }"
`; `;
@@ -742,11 +761,16 @@ exports[`lifecycle hooks willPatch, patched hook are called on subsubcomponents,
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`ChildChild\`, true, false, false, false); const comp1 = app.createComponent(\`ChildChild\`, true, false, false, false);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({n: ctx['props'].n}, key + \`__1\`, node, ctx, null); const b2 = text(\`
return block1([], [b2]); \`);
const b4 = comp1({n: ctx['props'].n}, key + \`__1\`, node, this, null);
const b3 = block3([], [b4]);
const b5 = text(\`
\`);
return multi([b2, b3, b5]);
} }
}" }"
`; `;
@@ -756,11 +780,16 @@ exports[`lifecycle hooks willPatch, patched hook are called on subsubcomponents,
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><block-text-0/></div>\`); let block3 = createBlock(\`<div><block-text-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let txt1 = ctx['props'].n; let txt1 = ctx['props'].n;
return block1([txt1]); const b3 = block3([txt1]);
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -772,7 +801,7 @@ exports[`lifecycle hooks willStart hook is called on sub component 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -822,17 +851,32 @@ exports[`lifecycle hooks willStart, mounted on subwidget rendered after main is
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); let block3 = createBlock(\`<div>
let block3 = createBlock(\`<div/>\`); <block-child-0/><block-child-1/>
</div>\`);
let block10 = createBlock(\`<div/>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; const b2 = text(\`
\`);
let b4,b8;
if (ctx['state'].ok) { if (ctx['state'].ok) {
b2 = comp1({}, key + \`__1\`, node, ctx, null); const b5 = text(\`
\`);
const b6 = comp1({}, key + \`__1\`, node, this, null);
const b7 = text(\`
\`);
b4 = multi([b5, b6, b7]);
} else { } else {
b3 = block3(); const b9 = text(\`
\`);
const b10 = block10();
const b11 = text(\`
\`);
b8 = multi([b9, b10, b11]);
} }
return block1([], [b2, b3]); const b3 = block3([], [b4, b8]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -857,7 +901,7 @@ exports[`lifecycle hooks willUpdateProps hook is called 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({n: ctx['state'].n}, key + \`__1\`, node, ctx, null); return comp1({n: ctx['state'].n}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -9,7 +9,7 @@ exports[`basics accept ES6-like syntax for props (with getters) 1`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({greetings: ctx['greetings']}, key + \`__1\`, node, ctx, null); const b2 = comp1({greetings: ctx['greetings']}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -37,16 +37,27 @@ exports[`basics arrow functions as prop correctly capture their scope 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block1, v_block1, l_block1, c_block1] = prepareList(ctx['items']);; const [k_block3, v_block3, l_block3, c_block3] = prepareList(ctx['items']);;
for (let i1 = 0; i1 < l_block1; i1++) { for (let i1 = 0; i1 < l_block3; i1++) {
ctx[\`item\`] = v_block1[i1]; ctx[\`item\`] = v_block3[i1];
const key1 = ctx['item'].val; const key1 = ctx['item'].val;
const b5 = text(\`
\`);
const v1 = ctx['onClick']; const v1 = ctx['onClick'];
const v2 = ctx['item']; const v2 = ctx['item'];
c_block1[i1] = withKey(comp1({onClick: _ev=>v1(v2.val,_ev)}, key + \`__1__\${key1}\`, node, ctx, null), key1); const b6 = comp1({onClick: _ev=>v1(v2.val,_ev)}, key + \`__1__\${key1}\`, node, this, null);
const b7 = text(\`
\`);
c_block3[i1] = withKey(multi([b5, b6, b7]), key1);
} }
return list(c_block1); ctx = ctx.__proto__;
const b3 = list(c_block3);
const b8 = text(\`
\`);
return multi([b2, b3, b8]);
} }
}" }"
`; `;
@@ -74,7 +85,7 @@ exports[`basics explicit object prop 1`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({value: ctx['state'].val}, key + \`__1\`, node, ctx, null); const b2 = comp1({value: ctx['state'].val}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -101,7 +112,7 @@ exports[`basics prop names can contain - 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({'prop-name': 7}, key + \`__1\`, node, ctx, null); return comp1({'prop-name': 7}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -127,7 +138,7 @@ exports[`basics support prop names that aren't valid bare object property names
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({'some-dashed-prop': 5}, key + \`__1\`, node, ctx, null); return comp1({'some-dashed-prop': 5}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -153,19 +164,25 @@ exports[`basics t-set with a body expression can be passed in props, and then t-
let { isBoundary, withDefault, LazyValue } = helpers; let { isBoundary, withDefault, LazyValue } = helpers;
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block2 = createBlock(\`<p>43</p>\`);
<block-child-0/>
</div>\`);
let block4 = createBlock(\`<p>43</p>\`);
function value1(ctx, node, key = \\"\\") { function value1(ctx, node, key = \\"\\") {
return block2(); return block4();
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
ctx[\`abc\`] = new LazyValue(value1, ctx, node); const b2 = text(\`
const b3 = comp1({val: ctx['abc']}, key + \`__1\`, node, ctx, null); \`);
return block1([], [b3]); ctx[\`abc\`] = new LazyValue(value1, ctx, this, node);
const b5 = comp1({val: ctx['abc']}, key + \`__1\`, node, this, null);
const b3 = block3([], [b5]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -176,12 +193,18 @@ exports[`basics t-set with a body expression can be passed in props, and then t-
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { safeOutput } = helpers; let { safeOutput } = helpers;
let block1 = createBlock(\`<span><block-text-0/><block-child-0/></span>\`); let block3 = createBlock(\`<span>
<block-text-0/>
<block-child-0/>
</span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let txt1 = ctx['props'].val; let txt1 = ctx['props'].val;
const b2 = safeOutput(ctx['props'].val); const b4 = safeOutput(ctx['props'].val);
return block1([txt1], [b2]); const b3 = block3([txt1], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -193,14 +216,20 @@ exports[`basics t-set with a body expression can be used as textual prop 1`] = `
let { isBoundary, withDefault, setContextValue } = helpers; let { isBoundary, withDefault, setContextValue } = helpers;
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
setContextValue(ctx, \\"abc\\", \`42\`); setContextValue(ctx, \\"abc\\", \`42\`);
const b2 = comp1({val: ctx['abc']}, key + \`__1\`, node, ctx, null); const b4 = comp1({val: ctx['abc']}, key + \`__1\`, node, this, null);
return block1([], [b2]); const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -226,14 +255,20 @@ exports[`basics t-set works 1`] = `
let { isBoundary, withDefault, setContextValue } = helpers; let { isBoundary, withDefault, setContextValue } = helpers;
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
setContextValue(ctx, \\"val\\", 42); setContextValue(ctx, \\"val\\", 42);
const b2 = comp1({val: ctx['val']}, key + \`__1\`, node, ctx, null); const b4 = comp1({val: ctx['val']}, key + \`__1\`, node, this, null);
return block1([], [b2]); const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -259,7 +294,7 @@ exports[`basics template string in prop 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({propName: \`1\${ctx['someVal']}3\`}, key + \`__1\`, node, ctx, null); return comp1({propName: \`1\${ctx['someVal']}3\`}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -283,7 +318,7 @@ exports[`bound functions is referentially equal after update 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({val: ctx['state'].val,fn: bind(ctx, ctx['someFunction'])}, key + \`__1\`, node, ctx, null); return comp1({val: ctx['state'].val,fn: bind(ctx, ctx['someFunction'])}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -307,7 +342,7 @@ exports[`can bind function prop with bind suffix 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({doSomething: bind(ctx, ctx['doSomething'])}, key + \`__1\`, node, ctx, null); return comp1({doSomething: bind(ctx, ctx['doSomething'])}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -9,7 +9,7 @@ exports[`default props a default prop cannot be defined on a mandatory prop 1`]
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {}; const props1 = {};
helpers.validateProps(\`Child\`, props1, ctx); helpers.validateProps(\`Child\`, props1, ctx);
return comp1(props1, key + \`__1\`, node, ctx, null); return comp1(props1, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -25,7 +25,7 @@ exports[`default props can set default boolean values 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {}; const props1 = {};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -62,7 +62,7 @@ exports[`default props can set default values 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {}; const props1 = {};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -93,7 +93,7 @@ exports[`default props default values are also set whenever component is updated
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['state'].p}; const props1 = {p: ctx['state'].p};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -122,7 +122,7 @@ exports[`props validation can specify that additional props are allowed (array)
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {message: 'm',otherProp: 'o'}; const props1 = {message: 'm',otherProp: 'o'};
helpers.validateProps(\`Child\`, props1, ctx); helpers.validateProps(\`Child\`, props1, ctx);
return comp1(props1, key + \`__1\`, node, ctx, null); return comp1(props1, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -149,7 +149,7 @@ exports[`props validation can specify that additional props are allowed (object)
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {message: 'm',otherProp: 'o'}; const props1 = {message: 'm',otherProp: 'o'};
helpers.validateProps(\`Child\`, props1, ctx); helpers.validateProps(\`Child\`, props1, ctx);
return comp1(props1, key + \`__1\`, node, ctx, null); return comp1(props1, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -178,7 +178,7 @@ exports[`props validation can validate a prop with multiple types 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -208,7 +208,7 @@ exports[`props validation can validate a prop with multiple types 3`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -238,7 +238,7 @@ exports[`props validation can validate a prop with multiple types 5`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -255,7 +255,7 @@ exports[`props validation can validate an array with given primitive type 1`] =
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -285,7 +285,7 @@ exports[`props validation can validate an array with given primitive type 3`] =
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -315,7 +315,7 @@ exports[`props validation can validate an array with given primitive type 5`] =
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -332,7 +332,7 @@ exports[`props validation can validate an array with given primitive type 6`] =
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -349,7 +349,7 @@ exports[`props validation can validate an array with multiple sub element types
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -379,7 +379,7 @@ exports[`props validation can validate an array with multiple sub element types
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -409,7 +409,7 @@ exports[`props validation can validate an array with multiple sub element types
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -439,7 +439,7 @@ exports[`props validation can validate an array with multiple sub element types
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -456,7 +456,7 @@ exports[`props validation can validate an object with simple shape 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -486,7 +486,7 @@ exports[`props validation can validate an object with simple shape 3`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -503,7 +503,7 @@ exports[`props validation can validate an object with simple shape 4`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -520,7 +520,7 @@ exports[`props validation can validate an object with simple shape 5`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -537,7 +537,7 @@ exports[`props validation can validate an optional props 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -567,7 +567,7 @@ exports[`props validation can validate an optional props 3`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -597,7 +597,7 @@ exports[`props validation can validate an optional props 5`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -614,7 +614,7 @@ exports[`props validation can validate recursively complicated prop def 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -644,7 +644,7 @@ exports[`props validation can validate recursively complicated prop def 3`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -674,7 +674,7 @@ exports[`props validation can validate recursively complicated prop def 5`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -691,7 +691,7 @@ exports[`props validation default values are applied before validating props at
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['state'].p}; const props1 = {p: ctx['state'].p};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -722,7 +722,7 @@ exports[`props validation missing required boolean prop causes an error 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {}; const props1 = {};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -739,7 +739,7 @@ exports[`props validation mix of optional and mandatory 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {}; const props1 = {};
helpers.validateProps(\`Child\`, props1, ctx); helpers.validateProps(\`Child\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -756,7 +756,7 @@ exports[`props validation props are validated in dev mode (code snapshot) 1`] =
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {message: 1}; const props1 = {message: 1};
helpers.validateProps(\`Child\`, props1, ctx); helpers.validateProps(\`Child\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -787,7 +787,7 @@ exports[`props validation props are validated whenever component is updated 1`]
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['state'].p}; const props1 = {p: ctx['state'].p};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -818,7 +818,7 @@ exports[`props validation props: list of strings 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {}; const props1 = {};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -835,7 +835,7 @@ exports[`props validation validate simple types 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -852,7 +852,7 @@ exports[`props validation validate simple types 2`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -882,7 +882,7 @@ exports[`props validation validate simple types 4`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -899,7 +899,7 @@ exports[`props validation validate simple types 5`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -916,7 +916,7 @@ exports[`props validation validate simple types 6`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -946,7 +946,7 @@ exports[`props validation validate simple types 8`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -963,7 +963,7 @@ exports[`props validation validate simple types 9`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -980,7 +980,7 @@ exports[`props validation validate simple types 10`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1010,7 +1010,7 @@ exports[`props validation validate simple types 12`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1027,7 +1027,7 @@ exports[`props validation validate simple types 13`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1044,7 +1044,7 @@ exports[`props validation validate simple types 14`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1074,7 +1074,7 @@ exports[`props validation validate simple types 16`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1091,7 +1091,7 @@ exports[`props validation validate simple types 17`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1108,7 +1108,7 @@ exports[`props validation validate simple types 18`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1138,7 +1138,7 @@ exports[`props validation validate simple types 20`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1155,7 +1155,7 @@ exports[`props validation validate simple types 21`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1172,7 +1172,7 @@ exports[`props validation validate simple types 22`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1202,7 +1202,7 @@ exports[`props validation validate simple types 24`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1219,7 +1219,7 @@ exports[`props validation validate simple types, alternate form 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1236,7 +1236,7 @@ exports[`props validation validate simple types, alternate form 2`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1266,7 +1266,7 @@ exports[`props validation validate simple types, alternate form 4`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1283,7 +1283,7 @@ exports[`props validation validate simple types, alternate form 5`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1300,7 +1300,7 @@ exports[`props validation validate simple types, alternate form 6`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1330,7 +1330,7 @@ exports[`props validation validate simple types, alternate form 8`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1347,7 +1347,7 @@ exports[`props validation validate simple types, alternate form 9`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1364,7 +1364,7 @@ exports[`props validation validate simple types, alternate form 10`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1394,7 +1394,7 @@ exports[`props validation validate simple types, alternate form 12`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1411,7 +1411,7 @@ exports[`props validation validate simple types, alternate form 13`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1428,7 +1428,7 @@ exports[`props validation validate simple types, alternate form 14`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1458,7 +1458,7 @@ exports[`props validation validate simple types, alternate form 16`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1475,7 +1475,7 @@ exports[`props validation validate simple types, alternate form 17`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1492,7 +1492,7 @@ exports[`props validation validate simple types, alternate form 18`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1522,7 +1522,7 @@ exports[`props validation validate simple types, alternate form 20`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1539,7 +1539,7 @@ exports[`props validation validate simple types, alternate form 21`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1556,7 +1556,7 @@ exports[`props validation validate simple types, alternate form 22`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1586,7 +1586,7 @@ exports[`props validation validate simple types, alternate form 24`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {p: ctx['p']}; const props1 = {p: ctx['p']};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1603,7 +1603,7 @@ exports[`props validation validation is only done in dev mode 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const props1 = {}; const props1 = {};
helpers.validateProps(\`SubComp\`, props1, ctx); helpers.validateProps(\`SubComp\`, props1, ctx);
const b2 = comp1(props1, key + \`__1\`, node, ctx, null); const b2 = comp1(props1, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -1618,7 +1618,7 @@ exports[`props validation validation is only done in dev mode 2`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b2 = comp1({}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -9,7 +9,7 @@ exports[`reactivity in lifecycle Child component doesn't render when state they
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; let b2;
if (ctx['state'].renderChild) { if (ctx['state'].renderChild) {
b2 = comp1({state: ctx['state']}, key + \`__1\`, node, ctx, null); b2 = comp1({state: ctx['state']}, key + \`__1\`, node, this, null);
} }
return multi([b2]); return multi([b2]);
} }
@@ -34,7 +34,7 @@ exports[`reactivity in lifecycle Component is automatically subscribed to reacti
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({obj: ctx['obj'],reactiveObj: ctx['reactiveObj']}, key + \`__1\`, node, ctx, null); return comp1({obj: ctx['obj'],reactiveObj: ctx['reactiveObj']}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -99,11 +99,16 @@ exports[`reactivity in lifecycle change state while mounting component 1`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><block-text-0/></div>\`); let block3 = createBlock(\`<div><block-text-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let txt1 = ctx['state'].val; let txt1 = ctx['state'].val;
return block1([txt1]); const b3 = block3([txt1]);
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -114,14 +119,21 @@ exports[`reactivity in lifecycle state changes in willUnmount do not trigger rer
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; const b2 = text(\`
\`);
let b4;
if (ctx['state'].flag) { if (ctx['state'].flag) {
b2 = comp1({val: ctx['state'].val}, key + \`__1\`, node, ctx, null); b4 = comp1({val: ctx['state'].val}, key + \`__1\`, node, this, null);
} }
return block1([], [b2]); const b3 = block3([], [b4]);
const b5 = text(\`
\`);
return multi([b2, b3, b5]);
} }
}" }"
`; `;
@@ -131,12 +143,17 @@ exports[`reactivity in lifecycle state changes in willUnmount do not trigger rer
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<span><block-text-0/><block-text-1/></span>\`); let block3 = createBlock(\`<span><block-text-0/><block-text-1/></span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let txt1 = ctx['props'].val; let txt1 = ctx['props'].val;
let txt2 = ctx['state'].n; let txt2 = ctx['state'].n;
return block1([txt1, txt2]); const b3 = block3([txt1, txt2]);
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -21,19 +21,31 @@ exports[`refs can use 2 refs with same name in a t-if/t-else situation 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { multiRefSetter } = helpers; let { multiRefSetter } = helpers;
let block2 = createBlock(\`<div block-ref=\\"0\\"/>\`); let block5 = createBlock(\`<div block-ref=\\"0\\"/>\`);
let block3 = createBlock(\`<span block-ref=\\"0\\"/>\`); let block9 = createBlock(\`<span block-ref=\\"0\\"/>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const refs = ctx.__owl__.refs; const refs = ctx.__owl__.refs;
const ref1 = multiRefSetter(refs, \`coucou\`); const ref1 = multiRefSetter(refs, \`coucou\`);
let b2,b3; let b2,b3,b7;
b2 = text(\`
\`);
if (ctx['state'].value) { if (ctx['state'].value) {
b2 = block2([ref1]); const b4 = text(\`
\`);
const b5 = block5([ref1]);
const b6 = text(\`
\`);
b3 = multi([b4, b5, b6]);
} else { } else {
b3 = block3([ref1]); const b8 = text(\`
\`);
const b9 = block9([ref1]);
const b10 = text(\`
\`);
b7 = multi([b8, b9, b10]);
} }
return multi([b2, b3]); return multi([b2, b3, b7]);
} }
}" }"
`; `;
@@ -44,17 +56,23 @@ exports[`refs refs and recursive templates 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Test\`, true, false, false, false); const comp1 = app.createComponent(\`Test\`, true, false, false, false);
let block1 = createBlock(\`<p block-ref=\\"0\\"><block-text-1/><block-child-0/></p>\`); let block3 = createBlock(\`<p block-ref=\\"0\\">
<block-text-1/>
<block-child-0/>
</p>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const refs = ctx.__owl__.refs; const refs = ctx.__owl__.refs;
const ref1 = (el) => refs[\`root\`] = el; const ref1 = (el) => refs[\`root\`] = el;
let b2; const b2 = text(\`
\`);
let b4;
let txt1 = ctx['props'].tree.value; let txt1 = ctx['props'].tree.value;
if (ctx['props'].tree.child) { if (ctx['props'].tree.child) {
b2 = comp1({tree: ctx['props'].tree.child}, key + \`__1\`, node, ctx, null); b4 = comp1({tree: ctx['props'].tree.child}, key + \`__1\`, node, this, null);
} }
return block1([ref1, txt1], [b2]); const b3 = block3([ref1, txt1], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -66,21 +84,37 @@ exports[`refs refs are properly bound in slots 1`] = `
let { capture, markRaw } = helpers; let { capture, markRaw } = helpers;
const comp1 = app.createComponent(\`Dialog\`, true, true, false, true); const comp1 = app.createComponent(\`Dialog\`, true, true, false, true);
let block1 = createBlock(\`<div><span class=\\"counter\\"><block-text-0/></span><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block2 = createBlock(\`<button block-handler-0=\\"click\\" block-ref=\\"1\\">do something</button>\`); <span class=\\"counter\\"><block-text-0/></span>
<block-child-0/>
</div>\`);
let block4 = createBlock(\`<button block-handler-0=\\"click\\" block-ref=\\"1\\">do something</button>\`);
function slot1(ctx, node, key = \\"\\") { function slot1(ctx, node, key = \\"\\") {
const refs = ctx.__owl__.refs; const refs = ctx.__owl__.refs;
const ref1 = (el) => refs[\`myButton\`] = el; const ref1 = (el) => refs[\`myButton\`] = el;
let hdlr1 = [ctx['doSomething'], ctx]; let hdlr1 = [ctx['doSomething'], ctx];
return block2([hdlr1, ref1]); return block4([hdlr1, ref1]);
}
function slot2(ctx, node, key = \\"\\") {
const b6 = text(\`
\`);
const b7 = text(\`
\`);
return multi([b6, b7]);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let txt1 = ctx['state'].val; let txt1 = ctx['state'].val;
const ctx1 = capture(ctx); const ctx1 = capture(ctx);
const b3 = comp1({slots: markRaw({'footer': {__render: slot1, __ctx: ctx1}})}, key + \`__1\`, node, ctx, null); const b8 = comp1({slots: markRaw({'footer': {__render: slot1, __ctx: ctx1}, 'default': {__render: slot2, __ctx: ctx1}})}, key + \`__1\`, node, this, null);
return block1([txt1], [b3]); const b3 = block3([txt1], [b8]);
const b9 = text(\`
\`);
return multi([b2, b3, b9]);
} }
}" }"
`; `;
@@ -106,15 +140,19 @@ exports[`refs throws if there are 2 same refs at the same time 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { multiRefSetter } = helpers; let { multiRefSetter } = helpers;
let block2 = createBlock(\`<div block-ref=\\"0\\"/>\`); let block3 = createBlock(\`<div block-ref=\\"0\\"/>\`);
let block3 = createBlock(\`<span block-ref=\\"0\\"/>\`); let block5 = createBlock(\`<span block-ref=\\"0\\"/>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const refs = ctx.__owl__.refs; const refs = ctx.__owl__.refs;
const ref1 = multiRefSetter(refs, \`coucou\`); const ref1 = multiRefSetter(refs, \`coucou\`);
const b2 = block2([ref1]); const b2 = text(\`
\`);
const b3 = block3([ref1]); const b3 = block3([ref1]);
return multi([b2, b3]); const b4 = text(\`
\`);
const b5 = block5([ref1]);
return multi([b2, b3, b4, b5]);
} }
}" }"
`; `;
@@ -7,9 +7,15 @@ exports[`children, default props and renderings 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(ctx['state'].value); const b2 = text(\`
const b3 = comp1({}, key + \`__1\`, node, ctx, null); \`);
return multi([b2, b3]); const b3 = text(ctx['state'].value);
const b4 = text(\`
\`);
const b5 = comp1({}, key + \`__1\`, node, this, null);
const b6 = text(\`
\`);
return multi([b2, b3, b4, b5, b6]);
} }
}" }"
`; `;
@@ -32,7 +38,7 @@ exports[`force render in case of existing render 1`] = `
const comp1 = app.createComponent(\`B\`, true, false, false, false); const comp1 = app.createComponent(\`B\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({val: ctx['state'].val}, key + \`__1\`, node, ctx, null); return comp1({val: ctx['state'].val}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -44,7 +50,7 @@ exports[`force render in case of existing render 2`] = `
const comp1 = app.createComponent(\`C\`, true, false, false, true); const comp1 = app.createComponent(\`C\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b2 = comp1({}, key + \`__1\`, node, this, null);
const b3 = text(ctx['props'].val); const b3 = text(ctx['props'].val);
return multi([b2, b3]); return multi([b2, b3]);
} }
@@ -69,9 +75,15 @@ exports[`rendering semantics can force a render to update sub tree 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(ctx['state'].value); const b2 = text(\`
const b3 = comp1({}, key + \`__1\`, node, ctx, null); \`);
return multi([b2, b3]); const b3 = text(ctx['state'].value);
const b4 = text(\`
\`);
const b5 = comp1({}, key + \`__1\`, node, this, null);
const b6 = text(\`
\`);
return multi([b2, b3, b4, b5, b6]);
} }
}" }"
`; `;
@@ -94,9 +106,15 @@ exports[`rendering semantics can render a parent without rendering child 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(ctx['state'].value); const b2 = text(\`
const b3 = comp1({}, key + \`__1\`, node, ctx, null); \`);
return multi([b2, b3]); const b3 = text(ctx['state'].value);
const b4 = text(\`
\`);
const b5 = comp1({}, key + \`__1\`, node, this, null);
const b6 = text(\`
\`);
return multi([b2, b3, b4, b5, b6]);
} }
}" }"
`; `;
@@ -119,7 +137,12 @@ exports[`rendering semantics props are reactive (nested prop) 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({a: ctx['state']}, key + \`__1\`, node, ctx, null); const b2 = text(\`
\`);
const b3 = comp1({a: ctx['state']}, key + \`__1\`, node, this, null);
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -142,7 +165,12 @@ exports[`rendering semantics props are reactive 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({a: ctx['state']}, key + \`__1\`, node, ctx, null); const b2 = text(\`
\`);
const b3 = comp1({a: ctx['state']}, key + \`__1\`, node, this, null);
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -165,9 +193,15 @@ exports[`rendering semantics render need a boolean = true to be 'deep' 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(ctx['state'].value); const b2 = text(\`
const b3 = comp1({}, key + \`__1\`, node, ctx, null); \`);
return multi([b2, b3]); const b3 = text(ctx['state'].value);
const b4 = text(\`
\`);
const b5 = comp1({}, key + \`__1\`, node, this, null);
const b6 = text(\`
\`);
return multi([b2, b3, b4, b5, b6]);
} }
}" }"
`; `;
@@ -192,7 +226,7 @@ exports[`rendering semantics render with deep=true followed by render with deep=
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`parent\`); const b2 = text(\`parent\`);
const b3 = text(ctx['state'].value); const b3 = text(ctx['state'].value);
const b4 = comp1({}, key + \`__1\`, node, ctx, null); const b4 = comp1({}, key + \`__1\`, node, this, null);
return multi([b2, b3, b4]); return multi([b2, b3, b4]);
} }
}" }"
@@ -219,7 +253,7 @@ exports[`rendering semantics rendering is atomic (for one subtree) 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(ctx['state'].obj.val); const b2 = text(ctx['state'].obj.val);
const b3 = comp1({obj: ctx['state'].obj}, key + \`__1\`, node, ctx, null); const b3 = comp1({obj: ctx['state'].obj}, key + \`__1\`, node, this, null);
return multi([b2, b3]); return multi([b2, b3]);
} }
}" }"
@@ -232,7 +266,7 @@ exports[`rendering semantics rendering is atomic (for one subtree) 2`] = `
const comp1 = app.createComponent(\`C\`, true, false, false, false); const comp1 = app.createComponent(\`C\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({obj: ctx['props'].obj}, key + \`__1\`, node, ctx, null); return comp1({obj: ctx['props'].obj}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -255,7 +289,12 @@ exports[`rendering semantics works as expected for dynamic number of props 1`] =
const comp1 = app.createComponent(\`Child\`, true, false, true, false); const comp1 = app.createComponent(\`Child\`, true, false, true, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1(Object.assign({}, ctx['state']), key + \`__1\`, node, ctx, null); const b2 = text(\`
\`);
const b3 = comp1(Object.assign({}, ctx['state']), key + \`__1\`, node, this, null);
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
File diff suppressed because it is too large Load Diff
@@ -7,7 +7,7 @@ exports[`style and class handling can set class on multi root component 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({class: 'fromparent'}, key + \`__1\`, node, ctx, null); return comp1({class: 'fromparent'}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -36,7 +36,7 @@ exports[`style and class handling can set class on sub component, as prop 1`] =
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({class: 'some-class'}, key + \`__1\`, node, ctx, null); return comp1({class: 'some-class'}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -62,7 +62,7 @@ exports[`style and class handling can set class on sub sub component 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({class: 'fromparent'}, key + \`__1\`, node, ctx, null); return comp1({class: 'fromparent'}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -74,7 +74,7 @@ exports[`style and class handling can set class on sub sub component 2`] = `
const comp1 = app.createComponent(\`ChildChild\`, true, false, false, false); const comp1 = app.createComponent(\`ChildChild\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({class: (ctx['props'].class||'')+' fromchild'}, key + \`__1\`, node, ctx, null); return comp1({class: (ctx['props'].class||'')+' fromchild'}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -100,7 +100,7 @@ exports[`style and class handling can set more than one class on sub component 1
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({class: 'a b'}, key + \`__1\`, node, ctx, null); return comp1({class: 'a b'}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -124,10 +124,15 @@ exports[`style and class handling can set style and class inside component 1`] =
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div style=\\"font-weight:bold;\\" class=\\"some-class\\">world</div>\`); let block3 = createBlock(\`<div style=\\"font-weight:bold;\\" class=\\"some-class\\">world</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return block1(); const b2 = text(\`
\`);
const b3 = block3();
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -153,7 +158,7 @@ exports[`style and class handling class on sub component, which is switched to a
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({class: 'someclass',child: ctx['state'].child}, key + \`__1\`, node, ctx, null); return comp1({class: 'someclass',child: ctx['state'].child}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -168,9 +173,9 @@ exports[`style and class handling class on sub component, which is switched to a
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; let b2,b3;
if (ctx['props'].child==='a') { if (ctx['props'].child==='a') {
b2 = comp1({class: ctx['props'].class}, key + \`__1\`, node, ctx, null); b2 = comp1({class: ctx['props'].class}, key + \`__1\`, node, this, null);
} else { } else {
b3 = comp2({class: ctx['props'].class}, key + \`__2\`, node, ctx, null); b3 = comp2({class: ctx['props'].class}, key + \`__2\`, node, this, null);
} }
return multi([b2, b3]); return multi([b2, b3]);
} }
@@ -214,7 +219,7 @@ exports[`style and class handling class with extra whitespaces (variation) 1`] =
let block1 = createBlock(\`<p><block-child-0/></p>\`); let block1 = createBlock(\`<p><block-child-0/></p>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({class: 'a b c d'}, key + \`__1\`, node, ctx, null); const b2 = comp1({class: 'a b c d'}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -241,7 +246,7 @@ exports[`style and class handling class with extra whitespaces 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({class: 'a b c d'}, key + \`__1\`, node, ctx, null); return comp1({class: 'a b c d'}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -267,7 +272,7 @@ exports[`style and class handling component class and parent class combine toget
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({class: 'from parent'}, key + \`__1\`, node, ctx, null); return comp1({class: 'from parent'}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -322,7 +327,7 @@ exports[`style and class handling empty class attribute is not added on widget r
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({class: undefined}, key + \`__1\`, node, ctx, null); const b2 = comp1({class: undefined}, key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -349,7 +354,7 @@ exports[`style and class handling error in subcomponent with class 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({class: 'a'}, key + \`__1\`, node, ctx, null); return comp1({class: 'a'}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -376,7 +381,7 @@ exports[`style and class handling no class is set is child ignores it 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({class: 'hey'}, key + \`__1\`, node, ctx, null); return comp1({class: 'hey'}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -401,7 +406,7 @@ exports[`style and class handling no class is set is parent does not give it as
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -427,7 +432,7 @@ exports[`style and class handling style is properly added on widget root el 1`]
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({style: 'font-weight: bold;'}, key + \`__1\`, node, ctx, null); return comp1({style: 'font-weight: bold;'}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -452,11 +457,16 @@ exports[`style and class handling t-att-class is properly added/removed on widge
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({class: {b:ctx['state'].b}}, key + \`__1\`, node, ctx, null); const b2 = text(\`
return block1([], [b2]); \`);
const b4 = comp1({class: {b:ctx['state'].b}}, key + \`__1\`, node, this, null);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -482,7 +492,7 @@ exports[`style and class handling t-att-class is properly added/removed on widge
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({class: {a:true,b:ctx['state'].b}}, key + \`__1\`, node, ctx, null); return comp1({class: {a:true,b:ctx['state'].b}}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -8,12 +8,17 @@ exports[`t-call dynamic t-call 1`] = `
const call = app.callTemplate.bind(app); const call = app.callTemplate.bind(app);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1; ctx[isBoundary] = 1;
const b1 = text(\` owl \`); const b3 = text(\`
ctx[zero] = b1; owl
\`);
ctx[zero] = b3;
const template1 = (ctx['current'].template); const template1 = (ctx['current'].template);
return call(this, template1, ctx, node, key + \`__1\`); const b4 = call(this, template1, ctx, node, key + \`__1\`);
return multi([b2, b4]);
} }
}" }"
`; `;
@@ -50,7 +55,7 @@ exports[`t-call dynamic t-call: key is propagated 1`] = `
const call = app.callTemplate.bind(app); const call = app.callTemplate.bind(app);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b2 = comp1({}, key + \`__1\`, node, this, null);
const template1 = (ctx['sub']); const template1 = (ctx['sub']);
const b3 = call(this, template1, ctx, node, key + \`__2\`); const b3 = call(this, template1, ctx, node, key + \`__2\`);
return multi([b2, b3]); return multi([b2, b3]);
@@ -79,7 +84,7 @@ exports[`t-call dynamic t-call: key is propagated 3`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -90,13 +95,16 @@ exports[`t-call handlers are properly bound through a dynamic t-call 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const call = app.callTemplate.bind(app); const call = app.callTemplate.bind(app);
let block1 = createBlock(\`<div><block-child-0/><block-text-0/></div>\`); let block3 = createBlock(\`<div><block-child-0/><block-text-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const template1 = ('__template__999'); const template1 = ('__template__999');
const b2 = call(this, template1, ctx, node, key + \`__1\`); const b4 = call(this, template1, ctx, node, key + \`__1\`);
let txt1 = ctx['counter']; let txt1 = ctx['counter'];
return block1([txt1], [b2]); const b3 = block3([txt1], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -121,12 +129,15 @@ exports[`t-call handlers are properly bound through a t-call 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const callTemplate_1 = app.getTemplate(\`__template__999\`); const callTemplate_1 = app.getTemplate(\`__template__999\`);
let block1 = createBlock(\`<div><block-child-0/><block-text-0/></div>\`); let block3 = createBlock(\`<div><block-child-0/><block-text-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`); const b2 = text(\`
\`);
const b4 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
let txt1 = ctx['counter']; let txt1 = ctx['counter'];
return block1([txt1], [b2]); const b3 = block3([txt1], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -197,7 +208,7 @@ exports[`t-call parent is set within t-call 2`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -234,7 +245,7 @@ exports[`t-call parent is set within t-call with no parentNode 2`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); return comp1({}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -259,16 +270,22 @@ exports[`t-call recursive t-call binding this -- static t-call 1`] = `
let { isBoundary, withDefault, setContextValue } = helpers; let { isBoundary, withDefault, setContextValue } = helpers;
const callTemplate_1 = app.getTemplate(\`recursive\`); const callTemplate_1 = app.getTemplate(\`recursive\`);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1; ctx[isBoundary] = 1;
setContextValue(ctx, \\"level\\", 0); setContextValue(ctx, \\"level\\", 0);
const b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`); const b4 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
return block1([], [b2]); ctx = ctx.__proto__;
const b3 = block3([], [b4]);
const b5 = text(\`
\`);
return multi([b2, b3, b5]);
} }
}" }"
`; `;
@@ -277,27 +294,43 @@ exports[`t-call recursive t-call binding this -- static t-call 2`] = `
"function anonymous(app, bdom, helpers "function anonymous(app, bdom, helpers
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue } = helpers; let { isBoundary, withDefault, setContextValue, zero } = helpers;
const callTemplate_1 = app.getTemplate(\`recursive\`); const callTemplate_1 = app.getTemplate(\`recursive\`);
let block3 = createBlock(\`<div block-handler-0=\\"click.stop\\"><block-text-1/></div>\`); let block5 = createBlock(\`<div block-handler-0=\\"click.stop\\"><block-text-1/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
let b2; let b2,b3,b12;
b2 = text(\`
\`);
if (ctx['level']<2) { if (ctx['level']<2) {
const b4 = text(\`
\`);
let hdlr1 = [\\"stop\\", ctx['onClicked'].bind(this), ctx]; let hdlr1 = [\\"stop\\", ctx['onClicked'].bind(this), ctx];
let txt1 = ctx['level']; let txt1 = ctx['level'];
const b3 = block3([hdlr1, txt1]); const b5 = block5([hdlr1, txt1]);
const b6 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1; ctx[isBoundary] = 1;
const b8 = text(\`
\`);
setContextValue(ctx, \\"level\\", ctx['level']+1); setContextValue(ctx, \\"level\\", ctx['level']+1);
const b4 = callTemplate_1.call(this, ctx, node, key + \`__1\`); const b9 = text(\`
\`);
const b7 = multi([b8, b9]);
ctx[zero] = b7;
const b10 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
ctx = ctx.__proto__; ctx = ctx.__proto__;
b2 = multi([b3, b4]); const b11 = text(\`
\`);
b3 = multi([b4, b5, b6, b10, b11]);
} }
return multi([b2]); b12 = text(\`
\`);
return multi([b2, b3, b12]);
} }
}" }"
`; `;
@@ -309,17 +342,24 @@ exports[`t-call sub components in two t-calls 1`] = `
const callTemplate_1 = app.getTemplate(\`sub\`); const callTemplate_1 = app.getTemplate(\`sub\`);
const callTemplate_2 = app.getTemplate(\`sub\`); const callTemplate_2 = app.getTemplate(\`sub\`);
let block3 = createBlock(\`<div><block-child-0/></div>\`); let block7 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; let b2,b3,b7;
b2 = text(\`
\`);
if (ctx['state'].val===1) { if (ctx['state'].val===1) {
b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`); const b4 = text(\`
\`);
const b5 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
const b6 = text(\`
\`);
b3 = multi([b4, b5, b6]);
} else { } else {
const b4 = callTemplate_2.call(this, ctx, node, key + \`__2\`); const b8 = callTemplate_2.call(this, ctx, node, key + \`__2\`);
b3 = block3([], [b4]); b7 = block7([], [b8]);
} }
return multi([b2, b3]); return multi([b2, b3, b7]);
} }
}" }"
`; `;
@@ -331,7 +371,7 @@ exports[`t-call sub components in two t-calls 2`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({val: ctx['state'].val}, key + \`__1\`, node, ctx, null); return comp1({val: ctx['state'].val}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -357,22 +397,33 @@ exports[`t-call t-call in t-foreach and children component 1`] = `
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
const callTemplate_1 = app.getTemplate(\`__template__999\`); const callTemplate_1 = app.getTemplate(\`__template__999\`);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(['a','b','c']);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(['a','b','c']);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`val\`] = v_block2[i1]; ctx[\`val\`] = v_block4[i1];
ctx[\`val_first\`] = i1 === 0; ctx[\`val_first\`] = i1 === 0;
ctx[\`val_last\`] = i1 === v_block2.length - 1; ctx[\`val_last\`] = i1 === v_block4.length - 1;
ctx[\`val_index\`] = i1; ctx[\`val_index\`] = i1;
ctx[\`val_value\`] = k_block2[i1]; ctx[\`val_value\`] = k_block4[i1];
const key1 = ctx['val']; const key1 = ctx['val'];
c_block2[i1] = withKey(callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`), key1); const b6 = text(\`
\`);
const b7 = callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`);
const b8 = text(\`
\`);
c_block4[i1] = withKey(multi([b6, b7, b8]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -384,7 +435,7 @@ exports[`t-call t-call in t-foreach and children component 2`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({val: ctx['val']}, key + \`__1\`, node, ctx, null); return comp1({val: ctx['val']}, key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -402,3 +453,82 @@ exports[`t-call t-call in t-foreach and children component 3`] = `
} }
}" }"
`; `;
exports[`t-call t-call with t-call-context and subcomponent 1`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const callTemplate_1 = app.getTemplate(\`someTemplate\`);
return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let ctx1 = ctx['subctx'];
const b3 = callTemplate_1.call(this, ctx1, node, key + \`__1\`);
return multi([b2, b3]);
}
}"
`;
exports[`t-call t-call with t-call-context and subcomponent 2`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, false);
const comp2 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const b3 = comp1({name: ctx['aab']}, key + \`__1\`, node, this, null);
const b4 = text(\`
\`);
const b5 = comp2({name: ctx['lpe']}, key + \`__2\`, node, this, null);
const b6 = text(\`
\`);
return multi([b2, b3, b4, b5, b6]);
}
}"
`;
exports[`t-call t-call with t-call-context and subcomponent 3`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
return function template(ctx, node, key = \\"\\") {
const b2 = text(\`child\`);
const b3 = text(ctx['props'].name);
return multi([b2, b3]);
}
}"
`;
exports[`t-call t-call with t-call-context, simple use 1`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const callTemplate_1 = app.getTemplate(\`someTemplate\`);
return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let ctx1 = ctx['subctx'];
const b3 = callTemplate_1.call(this, ctx1, node, key + \`__1\`);
return multi([b2, b3]);
}
}"
`;
exports[`t-call t-call with t-call-context, simple use 2`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
return function template(ctx, node, key = \\"\\") {
const b2 = text(ctx['aab']);
const b3 = text(ctx['lpe']);
return multi([b2, b3]);
}
}"
`;
@@ -6,12 +6,17 @@ exports[`t-component can switch between dynamic components without the need for
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(null, false, false, false, true); const comp1 = app.createComponent(null, false, false, false, true);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const Comp1 = ctx['constructor'].components[ctx['state'].child]; const Comp1 = ctx['constructor'].components[ctx['state'].child];
const b2 = toggler(Comp1, comp1({}, key + \`__1\`, node, ctx, Comp1)); const b4 = toggler(Comp1, comp1({}, key + \`__1\`, node, this, Comp1));
return block1([], [b2]); const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -51,7 +56,7 @@ exports[`t-component can use dynamic components (the class) if given (with diffe
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const tKey_1 = ctx['state'].child; const tKey_1 = ctx['state'].child;
const Comp1 = ctx['myComponent']; const Comp1 = ctx['myComponent'];
return toggler(tKey_1, toggler(Comp1, comp1({}, tKey_1 + key + \`__1\`, node, ctx, Comp1))); return toggler(tKey_1, toggler(Comp1, comp1({}, tKey_1 + key + \`__1\`, node, this, Comp1)));
} }
}" }"
`; `;
@@ -91,7 +96,7 @@ exports[`t-component can use dynamic components (the class) if given 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const tKey_1 = ctx['state'].child; const tKey_1 = ctx['state'].child;
const Comp1 = ctx['myComponent']; const Comp1 = ctx['myComponent'];
return toggler(tKey_1, toggler(Comp1, comp1({}, tKey_1 + key + \`__1\`, node, ctx, Comp1))); return toggler(tKey_1, toggler(Comp1, comp1({}, tKey_1 + key + \`__1\`, node, this, Comp1)));
} }
}" }"
`; `;
@@ -132,7 +137,7 @@ exports[`t-component modifying a sub widget 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const Comp1 = ctx['Counter']; const Comp1 = ctx['Counter'];
const b2 = toggler(Comp1, comp1({}, key + \`__1\`, node, ctx, Comp1)); const b2 = toggler(Comp1, comp1({}, key + \`__1\`, node, this, Comp1));
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -143,13 +148,16 @@ exports[`t-component modifying a sub widget 2`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><block-text-0/><button block-handler-1=\\"click\\">Inc</button></div>\`); let block3 = createBlock(\`<div><block-text-0/><button block-handler-1=\\"click\\">Inc</button></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let txt1 = ctx['state'].counter; let txt1 = ctx['state'].counter;
const v1 = ctx['state']; const v1 = ctx['state'];
let hdlr1 = [()=>v1.counter++, ctx]; let hdlr1 = [()=>v1.counter++, ctx];
return block1([txt1, hdlr1]); const b3 = block3([txt1, hdlr1]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -162,7 +170,7 @@ exports[`t-component switching dynamic component 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const Comp1 = ctx['Child']; const Comp1 = ctx['Child'];
return toggler(Comp1, comp1({}, key + \`__1\`, node, ctx, Comp1)); return toggler(Comp1, comp1({}, key + \`__1\`, node, this, Comp1));
} }
}" }"
`; `;
@@ -199,7 +207,7 @@ exports[`t-component t-component works in simple case 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const Comp1 = ctx['Child']; const Comp1 = ctx['Child'];
return toggler(Comp1, comp1({}, key + \`__1\`, node, ctx, Comp1)); return toggler(Comp1, comp1({}, key + \`__1\`, node, this, Comp1));
} }
}" }"
`; `;
@@ -7,20 +7,35 @@ exports[`list of components components in a node in a t-foreach 1`] = `
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
let block1 = createBlock(\`<div><ul><block-child-0/></ul></div>\`); let block3 = createBlock(\`<div>
let block3 = createBlock(\`<li><block-child-0/></li>\`); <ul>
<block-child-0/>
</ul>
</div>\`);
let block7 = createBlock(\`<li>
<block-child-0/>
</li>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['items']);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['items']);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`item\`] = v_block2[i1]; ctx[\`item\`] = v_block4[i1];
const key1 = 'li_'+ctx['item']; const key1 = 'li_'+ctx['item'];
const b4 = comp1({item: ctx['item']}, key + \`__1__\${key1}\`, node, ctx, null); const b6 = text(\`
c_block2[i1] = withKey(block3([], [b4]), key1); \`);
const b8 = comp1({item: ctx['item']}, key + \`__1__\${key1}\`, node, this, null);
const b7 = block7([], [b8]);
const b9 = text(\`
\`);
c_block4[i1] = withKey(multi([b6, b7, b9]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -47,19 +62,30 @@ exports[`list of components crash on duplicate key in dev mode 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block1, v_block1, l_block1, c_block1] = prepareList([1,2]);; const [k_block3, v_block3, l_block3, c_block3] = prepareList([1,2]);;
const keys1 = new Set(); const keys3 = new Set();
for (let i1 = 0; i1 < l_block1; i1++) { for (let i1 = 0; i1 < l_block3; i1++) {
ctx[\`item\`] = v_block1[i1]; ctx[\`item\`] = v_block3[i1];
const key1 = 'child'; const key1 = 'child';
if (keys1.has(key1)) { throw new Error(\`Got duplicate key in t-foreach: \${key1}\`)} if (keys3.has(key1)) { throw new Error(\`Got duplicate key in t-foreach: \${key1}\`)}
keys1.add(key1); keys3.add(key1);
const b5 = text(\`
\`);
const props1 = {}; const props1 = {};
helpers.validateProps(\`Child\`, props1, ctx); helpers.validateProps(\`Child\`, props1, ctx);
c_block1[i1] = withKey(comp1(props1, key + \`__1__\${key1}\`, node, ctx, null), key1); const b6 = comp1(props1, key + \`__1__\${key1}\`, node, this, null);
const b7 = text(\`
\`);
c_block3[i1] = withKey(multi([b5, b6, b7]), key1);
} }
return list(c_block1); ctx = ctx.__proto__;
const b3 = list(c_block3);
const b8 = text(\`
\`);
return multi([b2, b3, b8]);
} }
}" }"
`; `;
@@ -82,20 +108,28 @@ exports[`list of components list of sub components inside other nodes 1`] = `
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
const comp1 = app.createComponent(\`SubComponent\`, true, false, false, true); const comp1 = app.createComponent(\`SubComponent\`, true, false, false, true);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block3 = createBlock(\`<div><block-child-0/></div>\`); <block-child-0/>
</div>\`);
let block5 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['state'].blips);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['state'].blips);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`blip\`] = v_block2[i1]; ctx[\`blip\`] = v_block4[i1];
const key1 = ctx['blip'].id; const key1 = ctx['blip'].id;
const b4 = comp1({}, key + \`__1__\${key1}\`, node, ctx, null); const b6 = comp1({}, key + \`__1__\${key1}\`, node, this, null);
c_block2[i1] = withKey(block3([], [b4]), key1); c_block4[i1] = withKey(block5([], [b6]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -120,28 +154,44 @@ exports[`list of components reconciliation alg works for t-foreach in t-foreach
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['state'].s);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['state'].s);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`section\`] = v_block2[i1]; ctx[\`section\`] = v_block4[i1];
ctx[\`section_index\`] = i1; ctx[\`section_index\`] = i1;
const key1 = ctx['section_index']; const key1 = ctx['section_index'];
const b6 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block3, v_block3, l_block3, c_block3] = prepareList(ctx['section'].blips);; const [k_block7, v_block7, l_block7, c_block7] = prepareList(ctx['section'].blips);;
for (let i2 = 0; i2 < l_block3; i2++) { for (let i2 = 0; i2 < l_block7; i2++) {
ctx[\`blip\`] = v_block3[i2]; ctx[\`blip\`] = v_block7[i2];
ctx[\`blip_index\`] = i2; ctx[\`blip_index\`] = i2;
const key2 = ctx['blip_index']; const key2 = ctx['blip_index'];
c_block3[i2] = withKey(comp1({blip: ctx['blip']}, key + \`__1__\${key1}__\${key2}\`, node, ctx, null), key2); const b9 = text(\`
\`);
const b10 = comp1({blip: ctx['blip']}, key + \`__1__\${key1}__\${key2}\`, node, this, null);
const b11 = text(\`
\`);
c_block7[i2] = withKey(multi([b9, b10, b11]), key2);
} }
ctx = ctx.__proto__; ctx = ctx.__proto__;
c_block2[i1] = withKey(list(c_block3), key1); const b7 = list(c_block7);
const b12 = text(\`
\`);
c_block4[i1] = withKey(multi([b6, b7, b12]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -167,30 +217,40 @@ exports[`list of components reconciliation alg works for t-foreach in t-foreach,
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block3 = createBlock(\`<p><block-child-0/></p>\`); <block-child-0/>
let block5 = createBlock(\`<p><block-child-0/></p>\`); </div>\`);
let block5 = createBlock(\`<p>
<block-child-0/>
</p>\`);
let block7 = createBlock(\`<p>
<block-child-0/>
</p>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['state'].rows);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['state'].rows);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`row\`] = v_block2[i1]; ctx[\`row\`] = v_block4[i1];
const key1 = ctx['row']; const key1 = ctx['row'];
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['state'].cols);; const [k_block6, v_block6, l_block6, c_block6] = prepareList(ctx['state'].cols);;
for (let i2 = 0; i2 < l_block4; i2++) { for (let i2 = 0; i2 < l_block6; i2++) {
ctx[\`col\`] = v_block4[i2]; ctx[\`col\`] = v_block6[i2];
const key2 = ctx['col']; const key2 = ctx['col'];
const b6 = comp1({row: ctx['row'],col: ctx['col']}, key + \`__1__\${key1}__\${key2}\`, node, ctx, null); const b8 = comp1({row: ctx['row'],col: ctx['col']}, key + \`__1__\${key1}__\${key2}\`, node, this, null);
c_block4[i2] = withKey(block5([], [b6]), key2); c_block6[i2] = withKey(block7([], [b8]), key2);
} }
ctx = ctx.__proto__; ctx = ctx.__proto__;
const b4 = list(c_block4); const b6 = list(c_block6);
c_block2[i1] = withKey(block3([], [b4]), key1); c_block4[i1] = withKey(block5([], [b6]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -217,14 +277,22 @@ exports[`list of components simple list 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block1, v_block1, l_block1, c_block1] = prepareList(ctx['state'].elems);; const [k_block3, v_block3, l_block3, c_block3] = prepareList(ctx['state'].elems);;
for (let i1 = 0; i1 < l_block1; i1++) { for (let i1 = 0; i1 < l_block3; i1++) {
ctx[\`elem\`] = v_block1[i1]; ctx[\`elem\`] = v_block3[i1];
const key1 = ctx['elem'].id; const key1 = ctx['elem'].id;
c_block1[i1] = withKey(comp1({value: ctx['elem'].value}, key + \`__1__\${key1}\`, node, ctx, null), key1); const b5 = text(\`
\`);
const b6 = comp1({value: ctx['elem'].value}, key + \`__1__\${key1}\`, node, this, null);
const b7 = text(\`
\`);
c_block3[i1] = withKey(multi([b5, b6, b7]), key1);
} }
return list(c_block1); const b3 = list(c_block3);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -250,18 +318,29 @@ exports[`list of components sub components rendered in a loop 1`] = `
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['state'].numbers);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['state'].numbers);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`number\`] = v_block2[i1]; ctx[\`number\`] = v_block4[i1];
const key1 = ctx['number']; const key1 = ctx['number'];
c_block2[i1] = withKey(comp1({n: ctx['number']}, key + \`__1__\${key1}\`, node, ctx, null), key1); const b6 = text(\`
\`);
const b7 = comp1({n: ctx['number']}, key + \`__1__\${key1}\`, node, this, null);
const b8 = text(\`
\`);
c_block4[i1] = withKey(multi([b6, b7, b8]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -287,18 +366,29 @@ exports[`list of components sub components with some state rendered in a loop 1`
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['state'].numbers);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['state'].numbers);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`number\`] = v_block2[i1]; ctx[\`number\`] = v_block4[i1];
const key1 = ctx['number']; const key1 = ctx['number'];
c_block2[i1] = withKey(comp1({}, key + \`__1__\${key1}\`, node, ctx, null), key1); const b6 = text(\`
\`);
const b7 = comp1({}, key + \`__1__\${key1}\`, node, this, null);
const b8 = text(\`
\`);
c_block4[i1] = withKey(multi([b6, b7, b8]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -324,7 +414,9 @@ exports[`list of components switch component position 1`] = `
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
let block1 = createBlock(\`<span><block-child-0/></span>\`); let block1 = createBlock(\`<span>
<block-child-0/>
</span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
@@ -332,8 +424,14 @@ exports[`list of components switch component position 1`] = `
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block2; i1++) {
ctx[\`c\`] = v_block2[i1]; ctx[\`c\`] = v_block2[i1];
const key1 = ctx['c']; const key1 = ctx['c'];
c_block2[i1] = withKey(comp1({key: ctx['c']}, key + \`__1__\${key1}\`, node, ctx, null), key1); const b4 = text(\`
\`);
const b5 = comp1({key: ctx['c']}, key + \`__1__\${key1}\`, node, this, null);
const b6 = text(\`
\`);
c_block2[i1] = withKey(multi([b4, b5, b6]), key1);
} }
ctx = ctx.__proto__;
const b2 = list(c_block2); const b2 = list(c_block2);
return block1([], [b2]); return block1([], [b2]);
} }
@@ -361,19 +459,30 @@ exports[`list of components t-foreach with t-component, and update 1`] = `
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(Array(2));; const [k_block4, v_block4, l_block4, c_block4] = prepareList(Array(2));;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`n\`] = v_block2[i1]; ctx[\`n\`] = v_block4[i1];
ctx[\`n_index\`] = i1; ctx[\`n_index\`] = i1;
const key1 = ctx['n_index']; const key1 = ctx['n_index'];
c_block2[i1] = withKey(comp1({val: ctx['n_index']}, key + \`__1__\${key1}\`, node, ctx, null), key1); const b6 = text(\`
\`);
const b7 = comp1({val: ctx['n_index']}, key + \`__1__\${key1}\`, node, this, null);
const b8 = text(\`
\`);
c_block4[i1] = withKey(multi([b6, b7, b8]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -383,12 +492,18 @@ exports[`list of components t-foreach with t-component, and update 2`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<span><block-text-0/><block-text-1/></span>\`); let block3 = createBlock(\`<span>
<block-text-0/>
<block-text-1/>
</span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let txt1 = ctx['state'].val; let txt1 = ctx['state'].val;
let txt2 = ctx['props'].val; let txt2 = ctx['props'].val;
return block1([txt1, txt2]); const b3 = block3([txt1, txt2]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -7,7 +7,9 @@ exports[`t-key t-foreach with t-key switch component position 1`] = `
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
let block1 = createBlock(\`<span><block-child-0/></span>\`); let block1 = createBlock(\`<span>
<block-child-0/>
</span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
@@ -15,9 +17,15 @@ exports[`t-key t-foreach with t-key switch component position 1`] = `
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block2; i1++) {
ctx[\`c\`] = v_block2[i1]; ctx[\`c\`] = v_block2[i1];
const key1 = ctx['c']; const key1 = ctx['c'];
const b4 = text(\`
\`);
const tKey_1 = ctx['key1']; const tKey_1 = ctx['key1'];
c_block2[i1] = withKey(comp1({key: ctx['c']+ctx['key1']}, tKey_1 + key + \`__1__\${key1}\`, node, ctx, null), tKey_1 + key1); const b5 = toggler(tKey_1, comp1({key: ctx['c']+ctx['key1']}, tKey_1 + key + \`__1__\${key1}\`, node, this, null));
const b6 = text(\`
\`);
c_block2[i1] = withKey(multi([b4, b5, b6]), key1);
} }
ctx = ctx.__proto__;
const b2 = list(c_block2); const b2 = list(c_block2);
return block1([], [b2]); return block1([], [b2]);
} }
@@ -46,7 +54,7 @@ exports[`t-key t-key on Component 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const tKey_1 = ctx['key']; const tKey_1 = ctx['key'];
return toggler(tKey_1, comp1({key: ctx['key']}, tKey_1 + key + \`__1\`, node, ctx, null)); return toggler(tKey_1, comp1({key: ctx['key']}, tKey_1 + key + \`__1\`, node, this, null));
} }
}" }"
`; `;
@@ -75,7 +83,7 @@ exports[`t-key t-key on Component as a function 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const tKey_1 = ctx['key']; const tKey_1 = ctx['key'];
const b2 = toggler(tKey_1, comp1({key: ctx['key']}, tKey_1 + key + \`__1\`, node, ctx, null)); const b2 = toggler(tKey_1, comp1({key: ctx['key']}, tKey_1 + key + \`__1\`, node, this, null));
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -102,13 +110,16 @@ exports[`t-key t-key on multiple Components 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
const comp2 = app.createComponent(\`Child\`, true, false, false, false); const comp2 = app.createComponent(\`Child\`, true, false, false, false);
let block1 = createBlock(\`<span><block-child-0/><block-child-1/></span>\`); let block1 = createBlock(\`<span>
<block-child-0/>
<block-child-1/>
</span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const tKey_1 = ctx['key1']; const tKey_1 = ctx['key1'];
const b2 = toggler(tKey_1, comp1({key: ctx['key1']}, tKey_1 + key + \`__1\`, node, ctx, null)); const b2 = toggler(tKey_1, comp1({key: ctx['key1']}, tKey_1 + key + \`__1\`, node, this, null));
const tKey_2 = ctx['key2']; const tKey_2 = ctx['key2'];
const b3 = toggler(tKey_2, comp2({key: ctx['key2']}, tKey_2 + key + \`__2\`, node, ctx, null)); const b3 = toggler(tKey_2, comp2({key: ctx['key2']}, tKey_2 + key + \`__2\`, node, this, null));
return block1([], [b2, b3]); return block1([], [b2, b3]);
} }
}" }"
@@ -136,7 +147,10 @@ exports[`t-key t-key on multiple Components with t-call 1 1`] = `
const callTemplate_1 = app.getTemplate(\`calledTemplate\`); const callTemplate_1 = app.getTemplate(\`calledTemplate\`);
const callTemplate_2 = app.getTemplate(\`calledTemplate\`); const callTemplate_2 = app.getTemplate(\`calledTemplate\`);
let block1 = createBlock(\`<span><block-child-0/><block-child-1/></span>\`); let block1 = createBlock(\`<span>
<block-child-0/>
<block-child-1/>
</span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
@@ -150,6 +164,7 @@ exports[`t-key t-key on multiple Components with t-call 1 1`] = `
ctx[isBoundary] = 1; ctx[isBoundary] = 1;
setContextValue(ctx, \\"key\\", ctx['key2']); setContextValue(ctx, \\"key\\", ctx['key2']);
const b3 = callTemplate_2.call(this, ctx, node, key + \`__2\`); const b3 = callTemplate_2.call(this, ctx, node, key + \`__2\`);
ctx = ctx.__proto__;
return block1([], [b2, b3]); return block1([], [b2, b3]);
} }
}" }"
@@ -162,8 +177,13 @@ exports[`t-key t-key on multiple Components with t-call 1 2`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const tKey_1 = ctx['key']; const tKey_1 = ctx['key'];
return toggler(tKey_1, comp1({key: ctx['key']}, tKey_1 + key + \`__1\`, node, ctx, null)); const b3 = toggler(tKey_1, comp1({key: ctx['key']}, tKey_1 + key + \`__1\`, node, this, null));
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -188,7 +208,9 @@ exports[`t-key t-key on multiple Components with t-call 2 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const callTemplate_1 = app.getTemplate(\`calledTemplate\`); const callTemplate_1 = app.getTemplate(\`calledTemplate\`);
let block1 = createBlock(\`<span><block-child-0/></span>\`); let block1 = createBlock(\`<span>
<block-child-0/>
</span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`); const b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
@@ -205,11 +227,15 @@ exports[`t-key t-key on multiple Components with t-call 2 2`] = `
const comp2 = app.createComponent(\`Child\`, true, false, false, false); const comp2 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const tKey_1 = ctx['key1']; const tKey_1 = ctx['key1'];
const b2 = toggler(tKey_1, comp1({key: ctx['key1']}, tKey_1 + key + \`__1\`, node, ctx, null)); const b3 = toggler(tKey_1, comp1({key: ctx['key1']}, tKey_1 + key + \`__1\`, node, this, null));
const tKey_2 = ctx['key2']; const tKey_2 = ctx['key2'];
const b3 = toggler(tKey_2, comp2({key: ctx['key2']}, tKey_2 + key + \`__2\`, node, ctx, null)); const b4 = toggler(tKey_2, comp2({key: ctx['key2']}, tKey_2 + key + \`__2\`, node, this, null));
return multi([b2, b3]); const b5 = text(\`
\`);
return multi([b2, b3, b4, b5]);
} }
}" }"
`; `;
@@ -6,15 +6,23 @@ exports[`t-model directive .lazy modifier 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { toNumber } = helpers; let { toNumber } = helpers;
let block1 = createBlock(\`<div><input block-attribute-0=\\"value\\" block-handler-1=\\"change\\"/><span><block-text-2/></span></div>\`); let block3 = createBlock(\`<div>
<input block-attribute-0=\\"value\\" block-handler-1=\\"change\\"/>
<span><block-text-2/></span>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const bExpr1 = ctx['state']; const bExpr1 = ctx['state'];
const expr1 = 'text'; const expr1 = 'text';
let attr1 = bExpr1[expr1]; let attr1 = bExpr1[expr1];
let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.value; }]; let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.value; }];
let txt1 = ctx['state'].text; let txt1 = ctx['state'].text;
return block1([attr1, hdlr1, txt1]); const b3 = block3([attr1, hdlr1, txt1]);
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -25,15 +33,23 @@ exports[`t-model directive .number modifier 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { toNumber } = helpers; let { toNumber } = helpers;
let block1 = createBlock(\`<div><input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/><span><block-text-2/></span></div>\`); let block3 = createBlock(\`<div>
<input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/>
<span><block-text-2/></span>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const bExpr1 = ctx['state']; const bExpr1 = ctx['state'];
const expr1 = 'number'; const expr1 = 'number';
let attr1 = bExpr1[expr1]; let attr1 = bExpr1[expr1];
let hdlr1 = [(ev) => { bExpr1[expr1] = toNumber(ev.target.value); }]; let hdlr1 = [(ev) => { bExpr1[expr1] = toNumber(ev.target.value); }];
let txt1 = ctx['state'].number; let txt1 = ctx['state'].number;
return block1([attr1, hdlr1, txt1]); const b3 = block3([attr1, hdlr1, txt1]);
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -44,15 +60,23 @@ exports[`t-model directive .trim modifier 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { toNumber } = helpers; let { toNumber } = helpers;
let block1 = createBlock(\`<div><input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/><span><block-text-2/></span></div>\`); let block3 = createBlock(\`<div>
<input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/>
<span><block-text-2/></span>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const bExpr1 = ctx['state']; const bExpr1 = ctx['state'];
const expr1 = 'text'; const expr1 = 'text';
let attr1 = bExpr1[expr1]; let attr1 = bExpr1[expr1];
let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.value.trim(); }]; let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.value.trim(); }];
let txt1 = ctx['state'].text; let txt1 = ctx['state'].text;
return block1([attr1, hdlr1, txt1]); const b3 = block3([attr1, hdlr1, txt1]);
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -63,15 +87,21 @@ exports[`t-model directive basic use, on an input 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { toNumber } = helpers; let { toNumber } = helpers;
let block1 = createBlock(\`<div><input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/><span><block-text-2/></span></div>\`); let block3 = createBlock(\`<div>
<input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/>
<span><block-text-2/></span>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const bExpr1 = ctx['state']; const bExpr1 = ctx['state'];
const expr1 = 'text'; const expr1 = 'text';
let attr1 = bExpr1[expr1]; let attr1 = bExpr1[expr1];
let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.value; }]; let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.value; }];
let txt1 = ctx['state'].text; let txt1 = ctx['state'].text;
return block1([attr1, hdlr1, txt1]); const b3 = block3([attr1, hdlr1, txt1]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -82,15 +112,21 @@ exports[`t-model directive basic use, on an input with bracket expression 1`] =
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { toNumber } = helpers; let { toNumber } = helpers;
let block1 = createBlock(\`<div><input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/><span><block-text-2/></span></div>\`); let block3 = createBlock(\`<div>
<input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/>
<span><block-text-2/></span>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const bExpr1 = ctx['state']; const bExpr1 = ctx['state'];
const expr1 = 'text'; const expr1 = 'text';
let attr1 = bExpr1[expr1]; let attr1 = bExpr1[expr1];
let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.value; }]; let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.value; }];
let txt1 = ctx['state'].text; let txt1 = ctx['state'].text;
return block1([attr1, hdlr1, txt1]); const b3 = block3([attr1, hdlr1, txt1]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -101,7 +137,10 @@ exports[`t-model directive basic use, on another key in component 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { toNumber } = helpers; let { toNumber } = helpers;
let block1 = createBlock(\`<div><input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/><span><block-text-2/></span></div>\`); let block1 = createBlock(\`<div>
<input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/>
<span><block-text-2/></span>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const bExpr1 = ctx['some']; const bExpr1 = ctx['some'];
@@ -120,15 +159,22 @@ exports[`t-model directive can also define t-on directive on same event, part 1
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { toNumber } = helpers; let { toNumber } = helpers;
let block1 = createBlock(\`<div><input block-handler-0=\\"input\\" block-attribute-1=\\"value\\" block-handler-2=\\"input\\"/></div>\`); let block3 = createBlock(\`<div>
<input block-handler-0=\\"input\\" block-attribute-1=\\"value\\" block-handler-2=\\"input\\"/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let hdlr1 = [ctx['onInput'], ctx]; let hdlr1 = [ctx['onInput'], ctx];
const bExpr1 = ctx['state']; const bExpr1 = ctx['state'];
const expr1 = 'text'; const expr1 = 'text';
let attr1 = bExpr1[expr1]; let attr1 = bExpr1[expr1];
let hdlr2 = [(ev) => { bExpr1[expr1] = ev.target.value; }]; let hdlr2 = [(ev) => { bExpr1[expr1] = ev.target.value; }];
return block1([hdlr1, attr1, hdlr2]); const b3 = block3([hdlr1, attr1, hdlr2]);
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -139,9 +185,15 @@ exports[`t-model directive can also define t-on directive on same event, part 2
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { toNumber } = helpers; let { toNumber } = helpers;
let block1 = createBlock(\`<div><input type=\\"radio\\" id=\\"one\\" value=\\"One\\" block-handler-0=\\"click\\" block-attribute-1=\\"checked\\" block-handler-2=\\"click\\"/><input type=\\"radio\\" id=\\"two\\" value=\\"Two\\" block-handler-3=\\"click\\" block-attribute-4=\\"checked\\" block-handler-5=\\"click\\"/><input type=\\"radio\\" id=\\"three\\" value=\\"Three\\" block-handler-6=\\"click\\" block-attribute-7=\\"checked\\" block-handler-8=\\"click\\"/></div>\`); let block3 = createBlock(\`<div>
<input type=\\"radio\\" id=\\"one\\" value=\\"One\\" block-handler-0=\\"click\\" block-attribute-1=\\"checked\\" block-handler-2=\\"click\\"/>
<input type=\\"radio\\" id=\\"two\\" value=\\"Two\\" block-handler-3=\\"click\\" block-attribute-4=\\"checked\\" block-handler-5=\\"click\\"/>
<input type=\\"radio\\" id=\\"three\\" value=\\"Three\\" block-handler-6=\\"click\\" block-attribute-7=\\"checked\\" block-handler-8=\\"click\\"/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let hdlr1 = [ctx['onClick'], ctx]; let hdlr1 = [ctx['onClick'], ctx];
const bExpr1 = ctx['state']; const bExpr1 = ctx['state'];
const expr1 = 'choice'; const expr1 = 'choice';
@@ -157,7 +209,10 @@ exports[`t-model directive can also define t-on directive on same event, part 2
const expr3 = 'choice'; const expr3 = 'choice';
let attr3 = bExpr3[expr3] === 'Three'; let attr3 = bExpr3[expr3] === 'Three';
let hdlr6 = [(ev) => { bExpr3[expr3] = ev.target.value; }]; let hdlr6 = [(ev) => { bExpr3[expr3] = ev.target.value; }];
return block1([hdlr1, attr1, hdlr2, hdlr3, attr2, hdlr4, hdlr5, attr3, hdlr6]); const b3 = block3([hdlr1, attr1, hdlr2, hdlr3, attr2, hdlr4, hdlr5, attr3, hdlr6]);
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -168,17 +223,25 @@ exports[`t-model directive following a scope protecting directive (e.g. t-set) 1
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue, toNumber } = helpers; let { isBoundary, withDefault, setContextValue, toNumber } = helpers;
let block1 = createBlock(\`<div><input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/></div>\`); let block3 = createBlock(\`<div>
<input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
setContextValue(ctx, \\"admiral\\", 'Bruno'); setContextValue(ctx, \\"admiral\\", 'Bruno');
const bExpr1 = ctx['state']; const bExpr1 = ctx['state'];
const expr1 = 'text'; const expr1 = 'text';
let attr1 = bExpr1[expr1]; let attr1 = bExpr1[expr1];
let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.value; }]; let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.value; }];
return block1([attr1, hdlr1]); const b3 = block3([attr1, hdlr1]);
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -189,23 +252,36 @@ exports[`t-model directive in a t-foreach 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, toNumber, withKey } = helpers; let { prepareList, toNumber, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block3 = createBlock(\`<input type=\\"checkbox\\" block-attribute-0=\\"checked\\" block-handler-1=\\"input\\"/>\`); <block-child-0/>
</div>\`);
let block7 = createBlock(\`<input type=\\"checkbox\\" block-attribute-0=\\"checked\\" block-handler-1=\\"input\\"/>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['state']);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['state']);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`thing\`] = v_block2[i1]; ctx[\`thing\`] = v_block4[i1];
const key1 = ctx['thing'].id; const key1 = ctx['thing'].id;
const b6 = text(\`
\`);
const bExpr1 = ctx['thing']; const bExpr1 = ctx['thing'];
const expr1 = 'f'; const expr1 = 'f';
let attr1 = bExpr1[expr1]; let attr1 = bExpr1[expr1];
let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.checked; }]; let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.checked; }];
c_block2[i1] = withKey(block3([attr1, hdlr1]), key1); const b7 = block7([attr1, hdlr1]);
const b8 = text(\`
\`);
c_block4[i1] = withKey(multi([b6, b7, b8]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
const b9 = text(\`
\`);
return multi([b2, b3, b9]);
} }
}" }"
`; `;
@@ -216,24 +292,37 @@ exports[`t-model directive in a t-foreach, part 2 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, toNumber, withKey } = helpers; let { prepareList, toNumber, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block3 = createBlock(\`<input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/>\`); <block-child-0/>
</div>\`);
let block7 = createBlock(\`<input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['state']);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['state']);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`thing\`] = v_block2[i1]; ctx[\`thing\`] = v_block4[i1];
ctx[\`thing_index\`] = i1; ctx[\`thing_index\`] = i1;
const key1 = ctx['thing_index']; const key1 = ctx['thing_index'];
const b6 = text(\`
\`);
const bExpr1 = ctx['state']; const bExpr1 = ctx['state'];
const expr1 = ctx['thing_index']; const expr1 = ctx['thing_index'];
let attr1 = bExpr1[expr1]; let attr1 = bExpr1[expr1];
let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.value; }]; let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.value; }];
c_block2[i1] = withKey(block3([attr1, hdlr1]), key1); const b7 = block7([attr1, hdlr1]);
const b8 = text(\`
\`);
c_block4[i1] = withKey(multi([b6, b7, b8]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
const b9 = text(\`
\`);
return multi([b2, b3, b9]);
} }
}" }"
`; `;
@@ -244,24 +333,37 @@ exports[`t-model directive in a t-foreach, part 3 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, toNumber, withKey } = helpers; let { prepareList, toNumber, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block3 = createBlock(\`<input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/>\`); <block-child-0/>
</div>\`);
let block7 = createBlock(\`<input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['names']);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['names']);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`name\`] = v_block2[i1]; ctx[\`name\`] = v_block4[i1];
ctx[\`name_index\`] = i1; ctx[\`name_index\`] = i1;
const key1 = ctx['name_index']; const key1 = ctx['name_index'];
const b6 = text(\`
\`);
const bExpr1 = ctx['state'].values; const bExpr1 = ctx['state'].values;
const expr1 = ctx['name']; const expr1 = ctx['name'];
let attr1 = bExpr1[expr1]; let attr1 = bExpr1[expr1];
let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.value; }]; let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.value; }];
c_block2[i1] = withKey(block3([attr1, hdlr1]), key1); const b7 = block7([attr1, hdlr1]);
const b8 = text(\`
\`);
c_block4[i1] = withKey(multi([b6, b7, b8]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
const b9 = text(\`
\`);
return multi([b2, b3, b9]);
} }
}" }"
`; `;
@@ -272,7 +374,14 @@ exports[`t-model directive on a select 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { toNumber } = helpers; let { toNumber } = helpers;
let block1 = createBlock(\`<div><select block-attribute-0=\\"value\\" block-handler-1=\\"change\\"><option value=\\"\\">Please select one</option><option value=\\"red\\">Red</option><option value=\\"blue\\">Blue</option></select><span>Choice: <block-text-2/></span></div>\`); let block1 = createBlock(\`<div>
<select block-attribute-0=\\"value\\" block-handler-1=\\"change\\">
<option value=\\"\\">Please select one</option>
<option value=\\"red\\">Red</option>
<option value=\\"blue\\">Blue</option>
</select>
<span>Choice: <block-text-2/></span>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const bExpr1 = ctx['state']; const bExpr1 = ctx['state'];
@@ -291,14 +400,25 @@ exports[`t-model directive on a select, initial state 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { toNumber } = helpers; let { toNumber } = helpers;
let block1 = createBlock(\`<div><select block-attribute-0=\\"value\\" block-handler-1=\\"change\\"><option value=\\"\\">Please select one</option><option value=\\"red\\">Red</option><option value=\\"blue\\">Blue</option></select></div>\`); let block3 = createBlock(\`<div>
<select block-attribute-0=\\"value\\" block-handler-1=\\"change\\">
<option value=\\"\\">Please select one</option>
<option value=\\"red\\">Red</option>
<option value=\\"blue\\">Blue</option>
</select>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const bExpr1 = ctx['state']; const bExpr1 = ctx['state'];
const expr1 = 'color'; const expr1 = 'color';
let attr1 = bExpr1[expr1]; let attr1 = bExpr1[expr1];
let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.value; }]; let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.value; }];
return block1([attr1, hdlr1]); const b3 = block3([attr1, hdlr1]);
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -309,15 +429,23 @@ exports[`t-model directive on a sub state key 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { toNumber } = helpers; let { toNumber } = helpers;
let block1 = createBlock(\`<div><input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/><span><block-text-2/></span></div>\`); let block3 = createBlock(\`<div>
<input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/>
<span><block-text-2/></span>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const bExpr1 = ctx['state'].something; const bExpr1 = ctx['state'].something;
const expr1 = 'text'; const expr1 = 'text';
let attr1 = bExpr1[expr1]; let attr1 = bExpr1[expr1];
let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.value; }]; let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.value; }];
let txt1 = ctx['state'].something.text; let txt1 = ctx['state'].something.text;
return block1([attr1, hdlr1, txt1]); const b3 = block3([attr1, hdlr1, txt1]);
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -328,7 +456,11 @@ exports[`t-model directive on an input type=radio 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { toNumber } = helpers; let { toNumber } = helpers;
let block1 = createBlock(\`<div><input type=\\"radio\\" id=\\"one\\" value=\\"One\\" block-attribute-0=\\"checked\\" block-handler-1=\\"click\\"/><input type=\\"radio\\" id=\\"two\\" value=\\"Two\\" block-attribute-2=\\"checked\\" block-handler-3=\\"click\\"/><span>Choice: <block-text-4/></span></div>\`); let block1 = createBlock(\`<div>
<input type=\\"radio\\" id=\\"one\\" value=\\"One\\" block-attribute-0=\\"checked\\" block-handler-1=\\"click\\"/>
<input type=\\"radio\\" id=\\"two\\" value=\\"Two\\" block-attribute-2=\\"checked\\" block-handler-3=\\"click\\"/>
<span>Choice: <block-text-4/></span>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const bExpr1 = ctx['state']; const bExpr1 = ctx['state'];
@@ -351,7 +483,10 @@ exports[`t-model directive on an input type=radio, with initial value 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { toNumber } = helpers; let { toNumber } = helpers;
let block1 = createBlock(\`<div><input type=\\"radio\\" id=\\"one\\" value=\\"One\\" block-attribute-0=\\"checked\\" block-handler-1=\\"click\\"/><input type=\\"radio\\" id=\\"two\\" value=\\"Two\\" block-attribute-2=\\"checked\\" block-handler-3=\\"click\\"/></div>\`); let block1 = createBlock(\`<div>
<input type=\\"radio\\" id=\\"one\\" value=\\"One\\" block-attribute-0=\\"checked\\" block-handler-1=\\"click\\"/>
<input type=\\"radio\\" id=\\"two\\" value=\\"Two\\" block-attribute-2=\\"checked\\" block-handler-3=\\"click\\"/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const bExpr1 = ctx['state']; const bExpr1 = ctx['state'];
@@ -373,7 +508,12 @@ exports[`t-model directive on an input, type=checkbox 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { toNumber } = helpers; let { toNumber } = helpers;
let block1 = createBlock(\`<div><input type=\\"checkbox\\" block-attribute-0=\\"checked\\" block-handler-1=\\"input\\"/><span><block-child-0/><block-child-1/></span></div>\`); let block1 = createBlock(\`<div>
<input type=\\"checkbox\\" block-attribute-0=\\"checked\\" block-handler-1=\\"input\\"/>
<span>
<block-child-0/><block-child-1/>
</span>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; let b2,b3;
@@ -397,7 +537,10 @@ exports[`t-model directive on an textarea 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { toNumber } = helpers; let { toNumber } = helpers;
let block1 = createBlock(\`<div><textarea block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/><span><block-text-2/></span></div>\`); let block1 = createBlock(\`<div>
<textarea block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/>
<span><block-text-2/></span>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const bExpr1 = ctx['state']; const bExpr1 = ctx['state'];
@@ -434,9 +577,17 @@ exports[`t-model directive t-model on select with static options 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { toNumber } = helpers; let { toNumber } = helpers;
let block1 = createBlock(\`<div><select block-attribute-0=\\"value\\" block-handler-1=\\"change\\"><option value=\\"a\\"><block-text-2/></option><option value=\\"b\\"><block-text-3/></option><option value=\\"c\\"><block-text-4/></option></select></div>\`); let block3 = createBlock(\`<div>
<select block-attribute-0=\\"value\\" block-handler-1=\\"change\\">
<option value=\\"a\\"><block-text-2/></option>
<option value=\\"b\\"><block-text-3/></option>
<option value=\\"c\\"><block-text-4/></option>
</select>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const bExpr1 = ctx['state']; const bExpr1 = ctx['state'];
const expr1 = 'model'; const expr1 = 'model';
let attr1 = bExpr1[expr1]; let attr1 = bExpr1[expr1];
@@ -444,7 +595,10 @@ exports[`t-model directive t-model on select with static options 1`] = `
let txt1 = 'a'; let txt1 = 'a';
let txt2 = 'b'; let txt2 = 'b';
let txt3 = 'c'; let txt3 = 'c';
return block1([attr1, hdlr1, txt1, txt2, txt3]); const b3 = block3([attr1, hdlr1, txt1, txt2, txt3]);
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -455,9 +609,16 @@ exports[`t-model directive t-model with dynamic values on select options -- 2 1`
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { toNumber } = helpers; let { toNumber } = helpers;
let block1 = createBlock(\`<div><select block-handler-0=\\"change\\"><option block-attribute-1=\\"value\\" block-attribute-2=\\"selected\\"><block-text-3/></option><option block-attribute-4=\\"value\\" block-attribute-5=\\"selected\\"><block-text-6/></option></select></div>\`); let block3 = createBlock(\`<div>
<select block-handler-0=\\"change\\">
<option block-attribute-1=\\"value\\" block-attribute-2=\\"selected\\"><block-text-3/></option>
<option block-attribute-4=\\"value\\" block-attribute-5=\\"selected\\"><block-text-6/></option>
</select>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const bExpr1 = ctx['state']; const bExpr1 = ctx['state'];
const expr1 = 'model'; const expr1 = 'model';
const bValue1 = bExpr1[expr1]; const bValue1 = bExpr1[expr1];
@@ -468,7 +629,10 @@ exports[`t-model directive t-model with dynamic values on select options -- 2 1`
let attr3 = (ctx['options'][1]); let attr3 = (ctx['options'][1]);
let attr4 = bValue1 === (ctx['options'][1]); let attr4 = bValue1 === (ctx['options'][1]);
let txt2 = ctx['options'][1]; let txt2 = ctx['options'][1];
return block1([hdlr1, attr1, attr2, txt1, attr3, attr4, txt2]); const b3 = block3([hdlr1, attr1, attr2, txt1, attr3, attr4, txt2]);
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -479,9 +643,16 @@ exports[`t-model directive t-model with dynamic values on select options -- 3 1`
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { toNumber } = helpers; let { toNumber } = helpers;
let block1 = createBlock(\`<div><select block-handler-0=\\"change\\"><option block-attribute-1=\\"value\\" block-attribute-2=\\"selected\\"><block-text-3/></option><option value=\\"b\\" block-attribute-4=\\"selected\\"><block-text-5/></option></select></div>\`); let block3 = createBlock(\`<div>
<select block-handler-0=\\"change\\">
<option block-attribute-1=\\"value\\" block-attribute-2=\\"selected\\"><block-text-3/></option>
<option value=\\"b\\" block-attribute-4=\\"selected\\"><block-text-5/></option>
</select>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const bExpr1 = ctx['state']; const bExpr1 = ctx['state'];
const expr1 = 'model'; const expr1 = 'model';
const bValue1 = bExpr1[expr1]; const bValue1 = bExpr1[expr1];
@@ -491,7 +662,10 @@ exports[`t-model directive t-model with dynamic values on select options -- 3 1`
let txt1 = ctx['options'][0]; let txt1 = ctx['options'][0];
let attr3 = bValue1 === \\"b\\"; let attr3 = bValue1 === \\"b\\";
let txt2 = ctx['options'][1]; let txt2 = ctx['options'][1];
return block1([hdlr1, attr1, attr2, txt1, attr3, txt2]); const b3 = block3([hdlr1, attr1, attr2, txt1, attr3, txt2]);
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -502,9 +676,16 @@ exports[`t-model directive t-model with dynamic values on select options 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { toNumber } = helpers; let { toNumber } = helpers;
let block1 = createBlock(\`<div><select block-handler-0=\\"change\\"><option block-attribute-1=\\"value\\" block-attribute-2=\\"selected\\"><block-text-3/></option><option block-attribute-4=\\"value\\" block-attribute-5=\\"selected\\"><block-text-6/></option></select></div>\`); let block3 = createBlock(\`<div>
<select block-handler-0=\\"change\\">
<option block-attribute-1=\\"value\\" block-attribute-2=\\"selected\\"><block-text-3/></option>
<option block-attribute-4=\\"value\\" block-attribute-5=\\"selected\\"><block-text-6/></option>
</select>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const bExpr1 = ctx['state']; const bExpr1 = ctx['state'];
const expr1 = 'model'; const expr1 = 'model';
const bValue1 = bExpr1[expr1]; const bValue1 = bExpr1[expr1];
@@ -515,7 +696,10 @@ exports[`t-model directive t-model with dynamic values on select options 1`] = `
let attr3 = ctx['options'][1]; let attr3 = ctx['options'][1];
let attr4 = bValue1 === ctx['options'][1]; let attr4 = bValue1 === ctx['options'][1];
let txt2 = ctx['options'][1]; let txt2 = ctx['options'][1];
return block1([hdlr1, attr1, attr2, txt1, attr3, attr4, txt2]); const b3 = block3([hdlr1, attr1, attr2, txt1, attr3, attr4, txt2]);
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -526,26 +710,41 @@ exports[`t-model directive t-model with dynamic values on select options in fore
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { toNumber, prepareList, withKey } = helpers; let { toNumber, prepareList, withKey } = helpers;
let block1 = createBlock(\`<div><select block-handler-0=\\"change\\"><block-child-0/></select></div>\`); let block3 = createBlock(\`<div>
let block3 = createBlock(\`<option block-attribute-0=\\"value\\" block-attribute-1=\\"selected\\"><block-text-2/></option>\`); <select block-handler-0=\\"change\\">
<block-child-0/>
</select>
</div>\`);
let block7 = createBlock(\`<option block-attribute-0=\\"value\\" block-attribute-1=\\"selected\\"><block-text-2/></option>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const bExpr1 = ctx['state']; const bExpr1 = ctx['state'];
const expr1 = 'model'; const expr1 = 'model';
const bValue1 = bExpr1[expr1]; const bValue1 = bExpr1[expr1];
let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.value; }]; let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.value; }];
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['options']);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['options']);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`v\`] = v_block2[i1]; ctx[\`v\`] = v_block4[i1];
const key1 = ctx['v']; const key1 = ctx['v'];
const b6 = text(\`
\`);
let attr1 = ctx['v']; let attr1 = ctx['v'];
let attr2 = bValue1 === ctx['v']; let attr2 = bValue1 === ctx['v'];
let txt1 = ctx['v']; let txt1 = ctx['v'];
c_block2[i1] = withKey(block3([attr1, attr2, txt1]), key1); const b7 = block7([attr1, attr2, txt1]);
const b8 = text(\`
\`);
c_block4[i1] = withKey(multi([b6, b7, b8]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([hdlr1], [b2]); const b4 = list(c_block4);
const b3 = block3([hdlr1], [b4]);
const b9 = text(\`
\`);
return multi([b2, b3, b9]);
} }
}" }"
`; `;
@@ -556,27 +755,35 @@ exports[`t-model directive two inputs in a div alternating with a t-if 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { toNumber } = helpers; let { toNumber } = helpers;
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`); let block3 = createBlock(\`<div>
let block2 = createBlock(\`<input class=\\"a\\" block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/>\`); <block-child-0/>
let block3 = createBlock(\`<input class=\\"b\\" block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/>\`); <block-child-1/>
</div>\`);
let block4 = createBlock(\`<input class=\\"a\\" block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/>\`);
let block5 = createBlock(\`<input class=\\"b\\" block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2,b3; const b2 = text(\`
\`);
let b4,b5;
if (ctx['state'].flag) { if (ctx['state'].flag) {
const bExpr1 = ctx['state']; const bExpr1 = ctx['state'];
const expr1 = 'text1'; const expr1 = 'text1';
let attr1 = bExpr1[expr1]; let attr1 = bExpr1[expr1];
let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.value; }]; let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.value; }];
b2 = block2([attr1, hdlr1]); b4 = block4([attr1, hdlr1]);
} }
if (!ctx['state'].flag) { if (!ctx['state'].flag) {
const bExpr2 = ctx['state']; const bExpr2 = ctx['state'];
const expr2 = 'text2'; const expr2 = 'text2';
let attr2 = bExpr2[expr2]; let attr2 = bExpr2[expr2];
let hdlr2 = [(ev) => { bExpr2[expr2] = ev.target.value; }]; let hdlr2 = [(ev) => { bExpr2[expr2] = ev.target.value; }];
b3 = block3([attr2, hdlr2]); b5 = block5([attr2, hdlr2]);
} }
return block1([], [b2, b3]); const b3 = block3([], [b4, b5]);
const b6 = text(\`
\`);
return multi([b2, b3, b6]);
} }
}" }"
`; `;
@@ -587,15 +794,23 @@ exports[`t-model directive with expression having a changing key 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { toNumber } = helpers; let { toNumber } = helpers;
let block1 = createBlock(\`<div><input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/><span><block-text-2/></span></div>\`); let block3 = createBlock(\`<div>
<input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/>
<span><block-text-2/></span>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const bExpr1 = ctx['state'].something; const bExpr1 = ctx['state'].something;
const expr1 = ctx['text'].key; const expr1 = ctx['text'].key;
let attr1 = bExpr1[expr1]; let attr1 = bExpr1[expr1];
let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.value; }]; let hdlr1 = [(ev) => { bExpr1[expr1] = ev.target.value; }];
let txt1 = ctx['state'].something[ctx['text'].key]; let txt1 = ctx['state'].something[ctx['text'].key];
return block1([attr1, hdlr1, txt1]); const b3 = block3([attr1, hdlr1, txt1]);
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
+170 -63
View File
@@ -6,26 +6,38 @@ exports[`t-on t-on expression captured in t-foreach 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers; let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block3 = createBlock(\`<div><button block-handler-0=\\"click\\">expr</button></div>\`);
<block-child-0/>
</div>\`);
let block5 = createBlock(\`<div>
<button block-handler-0=\\"click\\">expr</button>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
setContextValue(ctx, \\"iter\\", 0); setContextValue(ctx, \\"iter\\", 0);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['arr']);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['arr']);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`val\`] = v_block2[i1]; ctx[\`val\`] = v_block4[i1];
const key1 = ctx['val']; const key1 = ctx['val'];
const v1 = ctx['otherState']; const v1 = ctx['otherState'];
const v2 = ctx['iter']; const v2 = ctx['iter'];
let hdlr1 = [()=>v1.vals.push(v2+'_'+v2), ctx]; let hdlr1 = [()=>v1.vals.push(v2+'_'+v2), ctx];
setContextValue(ctx, \\"iter\\", ctx['iter']+1); setContextValue(ctx, \\"iter\\", ctx['iter']+1);
c_block2[i1] = withKey(block3([hdlr1]), key1); c_block4[i1] = withKey(block5([hdlr1]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
const b6 = text(\`
\`);
return multi([b2, b3, b6]);
} }
}" }"
`; `;
@@ -36,14 +48,21 @@ exports[`t-on t-on expression in t-foreach 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block3 = createBlock(\`<div><block-text-0/>: <block-text-1/><button block-handler-2=\\"click\\">Expr</button></div>\`); <block-child-0/>
</div>\`);
let block5 = createBlock(\`<div>
<block-text-0/>: <block-text-1/>
<button block-handler-2=\\"click\\">Expr</button>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['state'].values);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['state'].values);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`val\`] = v_block2[i1]; ctx[\`val\`] = v_block4[i1];
ctx[\`val_index\`] = i1; ctx[\`val_index\`] = i1;
const key1 = ctx['val']; const key1 = ctx['val'];
let txt1 = ctx['val_index']; let txt1 = ctx['val_index'];
@@ -51,10 +70,14 @@ exports[`t-on t-on expression in t-foreach 1`] = `
const v1 = ctx['otherState']; const v1 = ctx['otherState'];
const v2 = ctx['val']; const v2 = ctx['val'];
let hdlr1 = [()=>v1.vals.push(v2), ctx]; let hdlr1 = [()=>v1.vals.push(v2), ctx];
c_block2[i1] = withKey(block3([txt1, txt2, hdlr1]), key1); c_block4[i1] = withKey(block5([txt1, txt2, hdlr1]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
const b6 = text(\`
\`);
return multi([b2, b3, b6]);
} }
}" }"
`; `;
@@ -65,17 +88,26 @@ exports[`t-on t-on expression in t-foreach with t-set 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers; let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block3 = createBlock(\`<div><block-text-0/>: <block-text-1/><button block-handler-2=\\"click\\">Expr</button></div>\`);
<block-child-0/>
</div>\`);
let block5 = createBlock(\`<div>
<block-text-0/>: <block-text-1/>
<button block-handler-2=\\"click\\">Expr</button>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
setContextValue(ctx, \\"bossa\\", 'nova'); setContextValue(ctx, \\"bossa\\", 'nova');
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['state'].values);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['state'].values);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`val\`] = v_block2[i1]; ctx[\`val\`] = v_block4[i1];
ctx[\`val_index\`] = i1; ctx[\`val_index\`] = i1;
const key1 = ctx['val']; const key1 = ctx['val'];
setContextValue(ctx, \\"bossa\\", ctx['bossa']+'_'+ctx['val_index']); setContextValue(ctx, \\"bossa\\", ctx['bossa']+'_'+ctx['val_index']);
@@ -85,10 +117,14 @@ exports[`t-on t-on expression in t-foreach with t-set 1`] = `
const v2 = ctx['val']; const v2 = ctx['val'];
const v3 = ctx['bossa']; const v3 = ctx['bossa'];
let hdlr1 = [()=>v1.vals.push(v2+'_'+v3), ctx]; let hdlr1 = [()=>v1.vals.push(v2+'_'+v3), ctx];
c_block2[i1] = withKey(block3([txt1, txt2, hdlr1]), key1); c_block4[i1] = withKey(block5([txt1, txt2, hdlr1]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
const b6 = text(\`
\`);
return multi([b2, b3, b6]);
} }
}" }"
`; `;
@@ -99,24 +135,35 @@ exports[`t-on t-on method call in t-foreach 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, withKey } = helpers; let { prepareList, withKey } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
let block3 = createBlock(\`<div><block-text-0/>: <block-text-1/><button block-handler-2=\\"click\\">meth call</button></div>\`); <block-child-0/>
</div>\`);
let block5 = createBlock(\`<div>
<block-text-0/>: <block-text-1/>
<button block-handler-2=\\"click\\">meth call</button>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['state'].values);; const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['state'].values);;
for (let i1 = 0; i1 < l_block2; i1++) { for (let i1 = 0; i1 < l_block4; i1++) {
ctx[\`val\`] = v_block2[i1]; ctx[\`val\`] = v_block4[i1];
ctx[\`val_index\`] = i1; ctx[\`val_index\`] = i1;
const key1 = ctx['val']; const key1 = ctx['val'];
let txt1 = ctx['val_index']; let txt1 = ctx['val_index'];
let txt2 = ctx['val']+''; let txt2 = ctx['val']+'';
const v1 = ctx['val']; const v1 = ctx['val'];
let hdlr1 = [()=>this.addVal(v1), ctx]; let hdlr1 = [()=>this.addVal(v1), ctx];
c_block2[i1] = withKey(block3([txt1, txt2, hdlr1]), key1); c_block4[i1] = withKey(block5([txt1, txt2, hdlr1]), key1);
} }
const b2 = list(c_block2); ctx = ctx.__proto__;
return block1([], [b2]); const b4 = list(c_block4);
const b3 = block3([], [b4]);
const b6 = text(\`
\`);
return multi([b2, b3, b6]);
} }
}" }"
`; `;
@@ -129,13 +176,19 @@ exports[`t-on t-on on component next to t-on on div 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
const catcher1 = createCatcher({\\"click\\":0}); const catcher1 = createCatcher({\\"click\\":0});
let block1 = createBlock(\`<div><block-child-0/><p block-handler-0=\\"click\\">dec</p></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
<p block-handler-0=\\"click\\">dec</p>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const hdlr1 = [ctx['increment'], ctx]; const hdlr1 = [ctx['increment'], ctx];
const b2 = catcher1(comp1({value: ctx['state'].value}, key + \`__1\`, node, ctx, null), [hdlr1]); const b4 = catcher1(comp1({value: ctx['state'].value}, key + \`__1\`, node, this, null), [hdlr1]);
let hdlr2 = [ctx['decrement'], ctx]; let hdlr2 = [ctx['decrement'], ctx];
return block1([hdlr2], [b2]); const b3 = block3([hdlr2], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -164,7 +217,7 @@ exports[`t-on t-on on components 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const hdlr1 = [ctx['increment'], ctx]; const hdlr1 = [ctx['increment'], ctx];
return catcher1(comp1({value: ctx['state'].value}, key + \`__1\`, node, ctx, null), [hdlr1]); return catcher1(comp1({value: ctx['state'].value}, key + \`__1\`, node, this, null), [hdlr1]);
} }
}" }"
`; `;
@@ -192,16 +245,24 @@ exports[`t-on t-on on components and t-foreach 1`] = `
const catcher1 = createCatcher({\\"click\\":0}); const catcher1 = createCatcher({\\"click\\":0});
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
ctx = Object.create(ctx); ctx = Object.create(ctx);
const [k_block1, v_block1, l_block1, c_block1] = prepareList(['John','Raoul','Gérald']);; const [k_block3, v_block3, l_block3, c_block3] = prepareList(['John','Raoul','Gérald']);;
for (let i1 = 0; i1 < l_block1; i1++) { for (let i1 = 0; i1 < l_block3; i1++) {
ctx[\`name\`] = v_block1[i1]; ctx[\`name\`] = v_block3[i1];
const key1 = ctx['name']; const key1 = ctx['name'];
const b5 = text(\`
\`);
const v1 = ctx['name']; const v1 = ctx['name'];
const hdlr1 = [()=>this.log(v1), ctx]; const hdlr1 = [()=>this.log(v1), ctx];
c_block1[i1] = withKey(catcher1(comp1({value: ctx['name']}, key + \`__1__\${key1}\`, node, ctx, null), [hdlr1]), key1); const b6 = catcher1(comp1({value: ctx['name']}, key + \`__1__\${key1}\`, node, this, null), [hdlr1]);
const b7 = text(\`
\`);
c_block3[i1] = withKey(multi([b5, b6, b7]), key1);
} }
return list(c_block1); const b3 = list(c_block3);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -228,12 +289,19 @@ exports[`t-on t-on on components, variation 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp1 = app.createComponent(\`Child\`, true, false, false, false);
const catcher1 = createCatcher({\\"click\\":0}); const catcher1 = createCatcher({\\"click\\":0});
let block1 = createBlock(\`<div><span/><block-child-0/><p/></div>\`); let block3 = createBlock(\`<div>
<span/>
<block-child-0/>
<p/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const hdlr1 = [ctx['increment'], ctx]; const hdlr1 = [ctx['increment'], ctx];
const b2 = catcher1(comp1({value: ctx['state'].value}, key + \`__1\`, node, ctx, null), [hdlr1]); const b4 = catcher1(comp1({value: ctx['state'].value}, key + \`__1\`, node, this, null), [hdlr1]);
return block1([], [b2]); const b3 = block3([], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -262,7 +330,7 @@ exports[`t-on t-on on components, with 'prevent' modifier 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const hdlr1 = [\\"prevent\\", ctx['increment'], ctx]; const hdlr1 = [\\"prevent\\", ctx['increment'], ctx];
return catcher1(comp1({value: ctx['state'].value}, key + \`__1\`, node, ctx, null), [hdlr1]); return catcher1(comp1({value: ctx['state'].value}, key + \`__1\`, node, this, null), [hdlr1]);
} }
}" }"
`; `;
@@ -292,10 +360,15 @@ exports[`t-on t-on on components, with a handler update 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
setContextValue(ctx, \\"name\\", ctx['state'].name); setContextValue(ctx, \\"name\\", ctx['state'].name);
const b3 = text(\`
\`);
const v1 = ctx['name']; const v1 = ctx['name'];
const hdlr1 = [()=>this.log(v1), ctx]; const hdlr1 = [()=>this.log(v1), ctx];
return catcher1(comp1({value: ctx['name']}, key + \`__1\`, node, ctx, null), [hdlr1]); const b4 = catcher1(comp1({value: ctx['name']}, key + \`__1\`, node, this, null), [hdlr1]);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -325,7 +398,7 @@ exports[`t-on t-on on destroyed components 1`] = `
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
let b2; let b2;
if (ctx['state'].flag) { if (ctx['state'].flag) {
b2 = comp1({}, key + \`__1\`, node, ctx, null); b2 = comp1({}, key + \`__1\`, node, this, null);
} }
return block1([], [b2]); return block1([], [b2]);
} }
@@ -353,14 +426,22 @@ exports[`t-on t-on on slot, with 'prevent' modifier 1`] = `
let { markRaw } = helpers; let { markRaw } = helpers;
const comp1 = app.createComponent(\`Child\`, true, true, false, true); const comp1 = app.createComponent(\`Child\`, true, true, false, true);
let block1 = createBlock(\`<button>button</button>\`); let block5 = createBlock(\`<button>button</button>\`);
function slot1(ctx, node, key = \\"\\") { function slot1(ctx, node, key = \\"\\") {
return block1(); const b4 = text(\`
\`);
const b5 = block5();
const b6 = text(\`
\`);
return multi([b4, b5, b6]);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__1\`, node, ctx, null); const b2 = text(\`
\`);
const b7 = comp1({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__1\`, node, this, null);
return multi([b2, b7]);
} }
}" }"
`; `;
@@ -387,23 +468,39 @@ exports[`t-on t-on on t-set-slots 1`] = `
const catcher1 = createCatcher({\\"click\\":0}); const catcher1 = createCatcher({\\"click\\":0});
const comp1 = app.createComponent(\`Child\`, true, true, false, true); const comp1 = app.createComponent(\`Child\`, true, true, false, true);
let block6 = createBlock(\`<p>something</p>\`); let block7 = createBlock(\`<p>something</p>\`);
let block7 = createBlock(\`<p>paragraph</p>\`); let block9 = createBlock(\`<p>paragraph</p>\`);
function slot1(ctx, node, key = \\"\\") { function slot1(ctx, node, key = \\"\\") {
const b6 = block6(); const b6 = text(\`
\`);
const b7 = block7(); const b7 = block7();
const b8 = text(\`
\`);
const b9 = block9();
const b10 = text(\`
\`);
const hdlr1 = [()=>this.state.count++, ctx]; const hdlr1 = [()=>this.state.count++, ctx];
return catcher1(multi([b6, b7]), [hdlr1]); return catcher1(multi([b6, b7, b8, b9, b10]), [hdlr1]);
}
function slot2(ctx, node, key = \\"\\") {
const b12 = text(\`
\`);
const b13 = text(\`
\`);
return multi([b12, b13]);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\` [\`); const b2 = text(\`
[\`);
const b3 = text(ctx['state'].count); const b3 = text(ctx['state'].count);
const b4 = text(\`] \`); const b4 = text(\`]
\`);
const ctx1 = capture(ctx); const ctx1 = capture(ctx);
const b8 = comp1({slots: markRaw({'myslot': {__render: slot1, __ctx: ctx1}})}, key + \`__1\`, node, ctx, null); const b14 = comp1({slots: markRaw({'myslot': {__render: slot1, __ctx: ctx1}, 'default': {__render: slot2, __ctx: ctx1}})}, key + \`__1\`, node, this, null);
return multi([b2, b3, b4, b8]); return multi([b2, b3, b4, b14]);
} }
}" }"
`; `;
@@ -427,14 +524,22 @@ exports[`t-on t-on on t-slots 1`] = `
let { markRaw } = helpers; let { markRaw } = helpers;
const comp1 = app.createComponent(\`Child\`, true, true, false, true); const comp1 = app.createComponent(\`Child\`, true, true, false, true);
let block1 = createBlock(\`<p>something</p>\`); let block5 = createBlock(\`<p>something</p>\`);
function slot1(ctx, node, key = \\"\\") { function slot1(ctx, node, key = \\"\\") {
return block1(); const b4 = text(\`
\`);
const b5 = block5();
const b6 = text(\`
\`);
return multi([b4, b5, b6]);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__1\`, node, ctx, null); const b2 = text(\`
\`);
const b7 = comp1({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__1\`, node, this, null);
return multi([b2, b7]);
} }
}" }"
`; `;
@@ -447,9 +552,11 @@ exports[`t-on t-on on t-slots 2`] = `
const catcher1 = createCatcher({\\"click\\":0}); const catcher1 = createCatcher({\\"click\\":0});
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\` [\`); const b2 = text(\`
[\`);
const b3 = text(ctx['state'].count); const b3 = text(ctx['state'].count);
const b4 = text(\`] \`); const b4 = text(\`]
\`);
const hdlr1 = [()=>this.state.count++, ctx]; const hdlr1 = [()=>this.state.count++, ctx];
const b5 = catcher1(callSlot(ctx, node, key, 'default', false, {}), [hdlr1]); const b5 = catcher1(callSlot(ctx, node, key, 'default', false, {}), [hdlr1]);
return multi([b2, b3, b4, b5]); return multi([b2, b3, b4, b5]);
@@ -6,11 +6,18 @@ exports[`t-props basic use 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, true, false); const comp1 = app.createComponent(\`Child\`, true, false, true, false);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1(Object.assign({}, ctx['some'].obj), key + \`__1\`, node, ctx, null); const b2 = text(\`
return block1([], [b2]); \`);
const b4 = comp1(Object.assign({}, ctx['some'].obj), key + \`__1\`, node, this, null);
const b3 = block3([], [b4]);
const b5 = text(\`
\`);
return multi([b2, b3, b5]);
} }
}" }"
`; `;
@@ -20,11 +27,18 @@ exports[`t-props basic use 2`] = `
) { ) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<span><block-text-0/></span>\`); let block3 = createBlock(\`<span>
<block-text-0/>
</span>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
let txt1 = ctx['props'].a+ctx['props'].b; let txt1 = ctx['props'].a+ctx['props'].b;
return block1([txt1]); const b3 = block3([txt1]);
const b4 = text(\`
\`);
return multi([b2, b3, b4]);
} }
}" }"
`; `;
@@ -36,7 +50,7 @@ exports[`t-props child receives a copy of the t-props object, not the original 1
const comp1 = app.createComponent(\`Child\`, true, false, true, false); const comp1 = app.createComponent(\`Child\`, true, false, true, false);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
return comp1(Object.assign({}, ctx['childProps']), key + \`__1\`, node, ctx, null); return comp1(Object.assign({}, ctx['childProps']), key + \`__1\`, node, this, null);
} }
}" }"
`; `;
@@ -63,7 +77,7 @@ exports[`t-props t-props and other props 1`] = `
let block1 = createBlock(\`<div><div><block-child-0/></div></div>\`); let block1 = createBlock(\`<div><div><block-child-0/></div></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1(Object.assign({}, ctx['state1'], {a: ctx['a']}), key + \`__1\`, node, ctx, null); const b2 = comp1(Object.assign({}, ctx['state1'], {a: ctx['a']}), key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -93,7 +107,7 @@ exports[`t-props t-props only 1`] = `
let block1 = createBlock(\`<div><div><block-child-0/></div></div>\`); let block1 = createBlock(\`<div><div><block-child-0/></div></div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1(Object.assign({}, ctx['state']), key + \`__1\`, node, ctx, null); const b2 = comp1(Object.assign({}, ctx['state']), key + \`__1\`, node, this, null);
return block1([], [b2]); return block1([], [b2]);
} }
}" }"
@@ -119,11 +133,18 @@ exports[`t-props t-props with props 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, true, false); const comp1 = app.createComponent(\`Child\`, true, false, true, false);
let block1 = createBlock(\`<div><block-child-0/></div>\`); let block3 = createBlock(\`<div>
<block-child-0/>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = comp1(Object.assign({}, ctx['childProps'], {a: 1,b: 2}), key + \`__1\`, node, ctx, null); const b2 = text(\`
return block1([], [b2]); \`);
const b4 = comp1(Object.assign({}, ctx['childProps'], {a: 1,b: 2}), key + \`__1\`, node, this, null);
const b3 = block3([], [b4]);
const b5 = text(\`
\`);
return multi([b2, b3, b5]);
} }
}" }"
`; `;
+190 -45
View File
@@ -7,24 +7,36 @@ exports[`t-set slot setted value (with t-set) not accessible with t-esc 1`] = `
let { isBoundary, withDefault, setContextValue, capture, markRaw } = helpers; let { isBoundary, withDefault, setContextValue, capture, markRaw } = helpers;
const comp1 = app.createComponent(\`Childcomp\`, true, true, false, true); const comp1 = app.createComponent(\`Childcomp\`, true, true, false, true);
let block1 = createBlock(\`<div><p><block-text-0/></p><block-child-0/><p><block-text-1/></p></div>\`); let block3 = createBlock(\`<div>
<p><block-text-0/></p>
<block-child-0/>
<p><block-text-1/></p>
</div>\`);
function slot1(ctx, node, key = \\"\\") { function slot1(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b5 = text(\`
\`);
setContextValue(ctx, \\"iter\\", 'inCall'); setContextValue(ctx, \\"iter\\", 'inCall');
return text(''); const b6 = text(\`
\`);
return multi([b5, b6]);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
setContextValue(ctx, \\"iter\\", 'source'); setContextValue(ctx, \\"iter\\", 'source');
let txt1 = ctx['iter']; let txt1 = ctx['iter'];
const ctx1 = capture(ctx); const ctx1 = capture(ctx);
const b2 = comp1({slots: markRaw({'default': {__render: slot1, __ctx: ctx1}})}, key + \`__1\`, node, ctx, null); const b7 = comp1({slots: markRaw({'default': {__render: slot1, __ctx: ctx1}})}, key + \`__1\`, node, this, null);
let txt2 = ctx['iter']; let txt2 = ctx['iter'];
return block1([txt1, txt2], [b2]); const b3 = block3([txt1, txt2], [b7]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -59,19 +71,33 @@ exports[`t-set slots with a t-set with a component in body 1`] = `
function slot1(ctx, node, key = \\"\\") { function slot1(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
ctx[\`v\`] = new LazyValue(value1, ctx, node); const b4 = text(\`
const b3 = text(\` in slot \`); \`);
const b4 = safeOutput(ctx['v']); ctx[\`v\`] = new LazyValue(value1, ctx, this, node);
return multi([b3, b4]); const b9 = text(\`
in slot
\`);
const b10 = safeOutput(ctx['v']);
const b11 = text(\`
\`);
return multi([b4, b9, b10, b11]);
} }
function value1(ctx, node, key = \\"\\") { function value1(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); const b6 = text(\`
\`);
const b7 = comp1({}, key + \`__1\`, node, this, null);
const b8 = text(\`
\`);
return multi([b6, b7, b8]);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const ctx1 = capture(ctx); const ctx1 = capture(ctx);
return comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx1}})}, key + \`__2\`, node, ctx, null); const b12 = comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx1}})}, key + \`__2\`, node, this, null);
return multi([b2, b12]);
} }
}" }"
`; `;
@@ -109,26 +135,41 @@ exports[`t-set slots with an t-set with a component in body 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
const comp2 = app.createComponent(\`Blorg\`, true, true, false, true); const comp2 = app.createComponent(\`Blorg\`, true, true, false, true);
let block4 = createBlock(\`<div>coffee</div>\`); let block9 = createBlock(\`<div>coffee</div>\`);
function slot1(ctx, node, key = \\"\\") { function slot1(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
ctx[\`v\`] = new LazyValue(value1, ctx, node); const b4 = text(\`
const b5 = text(\` tea \`); \`);
const b6 = safeOutput(ctx['v']); ctx[\`v\`] = new LazyValue(value1, ctx, this, node);
return multi([b5, b6]); const b11 = text(\`
tea
\`);
const b12 = safeOutput(ctx['v']);
const b13 = text(\`
\`);
return multi([b4, b11, b12, b13]);
} }
function value1(ctx, node, key = \\"\\") { function value1(ctx, node, key = \\"\\") {
const b3 = comp1({}, key + \`__1\`, node, ctx, null); const b6 = text(\`
const b4 = block4(); \`);
return multi([b3, b4]); const b7 = comp1({}, key + \`__1\`, node, this, null);
const b8 = text(\`
\`);
const b9 = block9();
const b10 = text(\`
\`);
return multi([b6, b7, b8, b9, b10]);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const ctx1 = capture(ctx); const ctx1 = capture(ctx);
return comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx1}})}, key + \`__2\`, node, ctx, null); const b14 = comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx1}})}, key + \`__2\`, node, this, null);
return multi([b2, b14]);
} }
}" }"
`; `;
@@ -169,17 +210,30 @@ exports[`t-set slots with an unused t-set with a component in body 1`] = `
function slot1(ctx, node, key = \\"\\") { function slot1(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
ctx[\`v\`] = new LazyValue(value1, ctx, node); const b4 = text(\`
return text(\` in slot \`); \`);
ctx[\`v\`] = new LazyValue(value1, ctx, this, node);
const b9 = text(\`
in slot
\`);
return multi([b4, b9]);
} }
function value1(ctx, node, key = \\"\\") { function value1(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); const b6 = text(\`
\`);
const b7 = comp1({}, key + \`__1\`, node, this, null);
const b8 = text(\`
\`);
return multi([b6, b7, b8]);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
const b2 = text(\`
\`);
const ctx1 = capture(ctx); const ctx1 = capture(ctx);
return comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx1}})}, key + \`__2\`, node, ctx, null); const b10 = comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx1}})}, key + \`__2\`, node, this, null);
return multi([b2, b10]);
} }
}" }"
`; `;
@@ -204,15 +258,22 @@ exports[`t-set t-set can't alter component even if key in component 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue } = helpers; let { isBoundary, withDefault, setContextValue } = helpers;
let block1 = createBlock(\`<div><p><block-text-0/></p><p><block-text-1/></p></div>\`); let block3 = createBlock(\`<div>
<p><block-text-0/></p>
<p><block-text-1/></p>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
let txt1 = ctx['iter']; let txt1 = ctx['iter'];
setContextValue(ctx, \\"iter\\", 5); setContextValue(ctx, \\"iter\\", 5);
let txt2 = ctx['iter']; let txt2 = ctx['iter'];
return block1([txt1, txt2]); const b3 = block3([txt1, txt2]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -223,15 +284,22 @@ exports[`t-set t-set can't alter component if key not in component 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue } = helpers; let { isBoundary, withDefault, setContextValue } = helpers;
let block1 = createBlock(\`<div><p><block-text-0/></p><p><block-text-1/></p></div>\`); let block3 = createBlock(\`<div>
<p><block-text-0/></p>
<p><block-text-1/></p>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
let txt1 = ctx['iter']; let txt1 = ctx['iter'];
setContextValue(ctx, \\"iter\\", 5); setContextValue(ctx, \\"iter\\", 5);
let txt2 = ctx['iter']; let txt2 = ctx['iter'];
return block1([txt1, txt2]); const b3 = block3([txt1, txt2]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -242,21 +310,44 @@ exports[`t-set t-set in t-if 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue } = helpers; let { isBoundary, withDefault, setContextValue } = helpers;
let block1 = createBlock(\`<div><block-child-0/><block-child-0/><block-child-0/><p><block-text-0/></p></div>\`); let block3 = createBlock(\`<div>
<block-child-0/><block-child-1/><block-child-2/>
<p><block-text-0/></p>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
let b4,b7,b10;
setContextValue(ctx, \\"flag\\", ctx['state'].flag); setContextValue(ctx, \\"flag\\", ctx['state'].flag);
if (ctx['flag']==='if') { if (ctx['flag']==='if') {
const b5 = text(\`
\`);
setContextValue(ctx, \\"iter\\", 2); setContextValue(ctx, \\"iter\\", 2);
const b6 = text(\`
\`);
b4 = multi([b5, b6]);
} else if (ctx['flag']==='elif') { } else if (ctx['flag']==='elif') {
const b8 = text(\`
\`);
setContextValue(ctx, \\"iter\\", 3); setContextValue(ctx, \\"iter\\", 3);
const b9 = text(\`
\`);
b7 = multi([b8, b9]);
} else { } else {
const b11 = text(\`
\`);
setContextValue(ctx, \\"iter\\", 4); setContextValue(ctx, \\"iter\\", 4);
const b12 = text(\`
\`);
b10 = multi([b11, b12]);
} }
let txt1 = ctx['iter']; let txt1 = ctx['iter'];
return block1([txt1]); const b3 = block3([txt1], [b4, b7, b10]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -268,16 +359,24 @@ exports[`t-set t-set not altered by child comp 1`] = `
let { isBoundary, withDefault, setContextValue } = helpers; let { isBoundary, withDefault, setContextValue } = helpers;
const comp1 = app.createComponent(\`Childcomp\`, true, false, false, true); const comp1 = app.createComponent(\`Childcomp\`, true, false, false, true);
let block1 = createBlock(\`<div><p><block-text-0/></p><block-child-0/><p><block-text-1/></p></div>\`); let block3 = createBlock(\`<div>
<p><block-text-0/></p>
<block-child-0/>
<p><block-text-1/></p>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
setContextValue(ctx, \\"iter\\", 'source'); setContextValue(ctx, \\"iter\\", 'source');
let txt1 = ctx['iter']; let txt1 = ctx['iter'];
const b2 = comp1({}, key + \`__1\`, node, ctx, null); const b4 = comp1({}, key + \`__1\`, node, this, null);
let txt2 = ctx['iter']; let txt2 = ctx['iter'];
return block1([txt1, txt2], [b2]); const b3 = block3([txt1, txt2], [b4]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -307,22 +406,46 @@ exports[`t-set t-set outside modified in t-if 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, setContextValue } = helpers; let { isBoundary, withDefault, setContextValue } = helpers;
let block1 = createBlock(\`<div><block-child-0/><block-child-0/><block-child-0/><p><block-text-0/></p></div>\`); let block3 = createBlock(\`<div>
<block-child-0/><block-child-1/><block-child-2/>
<p><block-text-0/></p>
</div>\`);
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
const b2 = text(\`
\`);
let b4,b7,b10;
setContextValue(ctx, \\"iter\\", 0); setContextValue(ctx, \\"iter\\", 0);
setContextValue(ctx, \\"flag\\", ctx['state'].flag); setContextValue(ctx, \\"flag\\", ctx['state'].flag);
if (ctx['flag']==='if') { if (ctx['flag']==='if') {
const b5 = text(\`
\`);
setContextValue(ctx, \\"iter\\", 2); setContextValue(ctx, \\"iter\\", 2);
const b6 = text(\`
\`);
b4 = multi([b5, b6]);
} else if (ctx['flag']==='elif') { } else if (ctx['flag']==='elif') {
const b8 = text(\`
\`);
setContextValue(ctx, \\"iter\\", 3); setContextValue(ctx, \\"iter\\", 3);
const b9 = text(\`
\`);
b7 = multi([b8, b9]);
} else { } else {
const b11 = text(\`
\`);
setContextValue(ctx, \\"iter\\", 4); setContextValue(ctx, \\"iter\\", 4);
const b12 = text(\`
\`);
b10 = multi([b11, b12]);
} }
let txt1 = ctx['iter']; let txt1 = ctx['iter'];
return block1([txt1]); const b3 = block3([txt1], [b4, b7, b10]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -334,18 +457,29 @@ exports[`t-set t-set with a component in body 1`] = `
let { isBoundary, withDefault, LazyValue, safeOutput } = helpers; let { isBoundary, withDefault, LazyValue, safeOutput } = helpers;
const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp1 = app.createComponent(\`Child\`, true, false, false, true);
let block1 = createBlock(\`<div><div><block-child-0/></div></div>\`); let block3 = createBlock(\`<div>
<div><block-child-0/></div>
</div>\`);
function value1(ctx, node, key = \\"\\") { function value1(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, ctx, null); const b5 = text(\`
\`);
const b6 = comp1({}, key + \`__1\`, node, this, null);
const b7 = text(\`
\`);
return multi([b5, b6, b7]);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
ctx[\`v\`] = new LazyValue(value1, ctx, node); const b2 = text(\`
const b3 = safeOutput(ctx['v']); \`);
return block1([], [b3]); ctx[\`v\`] = new LazyValue(value1, ctx, this, node);
const b8 = safeOutput(ctx['v']);
const b3 = block3([], [b8]);
return multi([b2, b3]);
} }
}" }"
`; `;
@@ -367,19 +501,30 @@ exports[`t-set t-set with something in body 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { isBoundary, withDefault, LazyValue, safeOutput } = helpers; let { isBoundary, withDefault, LazyValue, safeOutput } = helpers;
let block1 = createBlock(\`<div><div><block-child-0/></div></div>\`); let block3 = createBlock(\`<div>
let block2 = createBlock(\`<p>coucou</p>\`);
<div><block-child-0/></div>
</div>\`);
let block6 = createBlock(\`<p>coucou</p>\`);
function value1(ctx, node, key = \\"\\") { function value1(ctx, node, key = \\"\\") {
return block2(); const b5 = text(\`
\`);
const b6 = block6();
const b7 = text(\`
\`);
return multi([b5, b6, b7]);
} }
return function template(ctx, node, key = \\"\\") { return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx); ctx = Object.create(ctx);
ctx[isBoundary] = 1 ctx[isBoundary] = 1
ctx[\`v\`] = new LazyValue(value1, ctx, node); const b2 = text(\`
const b3 = safeOutput(ctx['v']); \`);
return block1([], [b3]); ctx[\`v\`] = new LazyValue(value1, ctx, this, node);
const b8 = safeOutput(ctx['v']);
const b3 = block3([], [b8]);
return multi([b2, b3]);
} }
}" }"
`; `;
+21
View File
@@ -1084,4 +1084,25 @@ describe("t-out in components", () => {
await nextTick(); await nextTick();
expect(fixture.innerHTML).toBe("<div>1</div><div>2</div>"); expect(fixture.innerHTML).toBe("<div>1</div><div>2</div>");
}); });
test("t-out and updating falsy values, ", async () => {
class Test extends Component {
static template = xml`<t t-out="state.a"/>`;
state: any = useState({ a: 0 });
}
const comp = await mount(Test, fixture);
expect(fixture.innerHTML).toBe("0");
comp.state.a = undefined;
await nextTick();
expect(fixture.innerHTML).toBe("");
comp.state.a = "hello";
await nextTick();
expect(fixture.innerHTML).toBe("hello");
comp.state.a = false;
await nextTick();
expect(fixture.innerHTML).toBe("false");
});
}); });
+43
View File
@@ -244,4 +244,47 @@ describe("t-call", () => {
} }
expect(clickCount).toBe(2); expect(clickCount).toBe(2);
}); });
test("t-call with t-call-context, simple use", async () => {
class Root extends Component {
static template = xml`
<t t-call="someTemplate" t-call-context="subctx"/>`;
subctx = { aab: "aaron", lpe: "lucas" };
}
await mount(Root, fixture, {
templates: `
<templates>
<t t-name="someTemplate"><t t-esc="aab"/><t t-esc="lpe"/></t>
</templates>`,
});
expect(fixture.innerHTML).toBe("aaronlucas");
});
test("t-call with t-call-context and subcomponent", async () => {
class Child extends Component {
static template = xml`child<t t-esc="props.name"/>`;
}
class Root extends Component {
static template = xml`
<t t-call="someTemplate" t-call-context="subctx"/>`;
static components = { Child };
subctx = { aab: "aaron", lpe: "lucas" };
}
await mount(Root, fixture, {
templates: `
<templates>
<t t-name="someTemplate">
<Child name="aab"/>
<Child name="lpe"/>
</t>
</templates>`,
});
expect(fixture.innerHTML).toBe("childaaronchildlucas");
});
}); });
File diff suppressed because it is too large Load Diff