From 3a361876ad3d3b1a3005f7dc9ff1d13eeb300c8a Mon Sep 17 00:00:00 2001 From: Mathieu Duckerts-Antoine Date: Fri, 19 Nov 2021 13:43:21 +0100 Subject: [PATCH] [IMP] slots: via prop 'slots' The slot inner working has been reworked. A prop "slots" is now passed explicitely to the component. It looks like { slotName_1: slotInfo_1, ..., slotName_m: slotInfo_m } with the objects slotInfo_i with mandatory keys "__render", "__ctx", and optional key "__scope" and possibly others. Here is how a slotInfo object can be created: A slotInfo object is normally created by setting in a template something like
content
and it will be used somewhere like
In the above example, the function "__render" produces the block dom element for the content of the t-set-slot. The context "__ctx" will have a key "scope" with value { bool: ..., num: 5 } and "__scope" will be set to "scope". --- src/app/template_helpers.ts | 15 +- src/compiler/code_generator.ts | 119 ++-- src/compiler/parser.ts | 37 +- src/component/component_node.ts | 1 - src/memo.ts | 2 +- tests/compiler/parser.test.ts | 130 ++-- .../__snapshots__/error_handling.test.ts.snap | 85 ++- .../props_validation.test.ts.snap | 180 ++--- .../__snapshots__/refs.test.ts.snap | 9 +- .../__snapshots__/slots.test.ts.snap | 622 ++++++++++-------- .../__snapshots__/t_foreach.test.ts.snap | 6 +- .../__snapshots__/t_set.test.ts.snap | 7 +- tests/components/slots.test.ts | 82 +++ tests/misc/__snapshots__/memo.test.ts.snap | 17 +- tests/misc/__snapshots__/portal.test.ts.snap | 116 ++-- 15 files changed, 824 insertions(+), 604 deletions(-) diff --git a/src/app/template_helpers.ts b/src/app/template_helpers.ts index 8cbf2133..fa29c95f 100644 --- a/src/app/template_helpers.ts +++ b/src/app/template_helpers.ts @@ -17,12 +17,17 @@ function callSlot( parent: any, key: string, name: string, - defaultSlot?: (ctx: any, key: string) => BDom, - dynamic?: boolean + dynamic: boolean, + extra: any, + defaultSlot?: (ctx: any, key: string) => BDom ): BDom { - const slots = ctx.__owl__.slots; - const slotFn = slots[name]; - const slotBDom = slotFn ? slotFn(parent, key) : null; + const slots = (ctx.props && ctx.props.slots) || {}; + const { __render, __ctx, __scope } = slots[name] || {}; + const slotScope = Object.create(__ctx || {}); + if (__scope) { + slotScope[__scope] = extra || {}; + } + const slotBDom = __render ? __render(slotScope, parent, key) : null; if (defaultSlot) { let child1: BDom | undefined = undefined; let child2: BDom | undefined = undefined; diff --git a/src/compiler/code_generator.ts b/src/compiler/code_generator.ts index ce5a13a8..5201d0e5 100644 --- a/src/compiler/code_generator.ts +++ b/src/compiler/code_generator.ts @@ -962,13 +962,62 @@ export class CodeGenerator { compileComponent(ast: ASTComponent, ctx: Context) { let { block } = ctx; - let extraArgs: { [key: string]: string } = {}; // props const props: string[] = []; + let hasSlotsProp = false; for (let p in ast.props) { props.push(`${p}: ${this.captureExpression(ast.props[p]) || undefined}`); + if (p === "slots") { + hasSlotsProp = true; + } } + + // slots + const hasSlot = !!Object.keys(ast.slots).length; + let slotDef: string = ""; + if (hasSlot) { + let ctxStr = "ctx"; + if (this.target.loopLevel || !this.hasSafeContext) { + ctxStr = this.generateId("ctx"); + this.addLine(`const ${ctxStr} = capture(ctx);`); + } + let slotStr: string[] = []; + const initialTarget = this.target; + for (let slotName in ast.slots) { + let name = this.generateId("slot"); + const slot = new CodeTarget(name); + slot.signature = "(ctx, node, key) => {"; + this.functions.push(slot); + this.target = slot; + const subCtx: Context = createContext(ctx); + this.compileAST(ast.slots[slotName].content, subCtx); + const params = [`__render: ${name}, __ctx: ${ctxStr}`]; + const scope = ast.slots[slotName].scope; + if (scope) { + params.push(`__scope: "${scope}"`); + } + if (ast.slots[slotName].attrs) { + for (const [n, v] of Object.entries(ast.slots[slotName].attrs!)) { + params.push(`${n}: ${compileExpr(v) || undefined}`); + } + } + const slotInfo = `{${params.join(", ")}}`; + if (this.hasRef) { + slot.code.unshift(` const refs = ctx.__owl__.refs`); + slotStr.push(`'${slotName}': ${slotInfo}`); + } else { + slotStr.push(`'${slotName}': ${slotInfo}`); + } + } + this.target = initialTarget; + slotDef = `{${slotStr.join(", ")}}`; + } + + if (slotDef && !(ast.dynamicProps || hasSlotsProp)) { + props.push(`slots: ${slotDef}`); + } + const propStr = `{${props.join(",")}}`; let propString = propStr; @@ -980,6 +1029,17 @@ export class CodeGenerator { } } + let propVar: string; + if ((slotDef && (ast.dynamicProps || hasSlotsProp)) || this.dev) { + propVar = this.generateId("props"); + this.addLine(`const ${propVar!} = ${propString}`); + propString = propVar!; + } + + if (slotDef && (ast.dynamicProps || hasSlotsProp)) { + this.addLine(`${propVar!}.slots = Object.assign(${slotDef}, ${propVar!}.slots)`); + } + // cmap key const key = this.generateComponentKey(); let expr: string; @@ -991,41 +1051,7 @@ export class CodeGenerator { } if (this.dev) { - const propVar = this.generateId("props"); - this.addLine(`const ${propVar} = ${propString}`); - this.addLine(`helpers.validateProps(${expr}, ${propVar}, ctx)`); - propString = propVar; - } - - // slots - const hasSlot = !!Object.keys(ast.slots).length; - let slotDef: string; - if (hasSlot) { - let ctxStr = "ctx"; - if (this.target.loopLevel || !this.hasSafeContext) { - ctxStr = this.generateId("ctx"); - this.addLine(`const ${ctxStr} = capture(ctx);`); - } - let slotStr: string[] = []; - const initialTarget = this.target; - for (let slotName in ast.slots) { - let name = this.generateId("slot"); - const slot = new CodeTarget(name); - slot.signature = "ctx => (node, key) => {"; - this.functions.push(slot); - this.target = slot; - const subCtx: Context = createContext(ctx); - this.compileAST(ast.slots[slotName], subCtx); - if (this.hasRef) { - slot.code.unshift(` const refs = ctx.__owl__.refs`); - slotStr.push(`'${slotName}': ${name}(${ctxStr})`); - } else { - slotStr.push(`'${slotName}': ${name}(${ctxStr})`); - } - } - this.target = initialTarget; - slotDef = `{${slotStr.join(", ")}}`; - extraArgs.slots = slotDef; + this.addLine(`helpers.validateProps(${expr}, ${propVar!}, ctx)`); } if (block && (ctx.forceNewBlock === false || ctx.tKeyExpr)) { @@ -1039,11 +1065,6 @@ export class CodeGenerator { } const blockArgs = `${expr}, ${propString}, ${keyArg}, node, ctx`; let blockExpr = `component(${blockArgs})`; - if (Object.keys(extraArgs).length) { - this.shouldDefineAssign = true; - const content = Object.keys(extraArgs).map((k) => `${k}: ${extraArgs[k]}`); - blockExpr = `assign(${blockExpr}, {${content.join(", ")}})`; - } if (ast.isDynamic) { blockExpr = `toggler(${expr}, ${blockExpr})`; } @@ -1062,6 +1083,16 @@ export class CodeGenerator { } else { slotName = "'" + ast.name + "'"; } + + let scope = null; + if (ast.attrs) { + const params = []; + for (const [n, v] of Object.entries(ast.attrs!)) { + params.push(`${n}: ${compileExpr(v) || undefined}`); + } + scope = `{${params.join(", ")}}`; + } + if (ast.defaultContent) { let name = this.generateId("defaultSlot"); const slot = new CodeTarget(name); @@ -1072,14 +1103,14 @@ export class CodeGenerator { this.target = slot; this.compileAST(ast.defaultContent, subCtx); this.target = initialTarget; - blockString = `callSlot(ctx, node, key, ${slotName}, ${name}, ${dynamic})`; + blockString = `callSlot(ctx, node, key, ${slotName}, ${dynamic}, ${scope}, ${name})`; } else { if (dynamic) { let name = this.generateId("slot"); this.addLine(`const ${name} = ${slotName};`); - blockString = `toggler(${name}, callSlot(ctx, node, key, ${name}))`; + blockString = `toggler(${name}, callSlot(ctx, node, key, ${name}), ${dynamic}, ${scope})`; } else { - blockString = `callSlot(ctx, node, key, ${slotName})`; + blockString = `callSlot(ctx, node, key, ${slotName}, ${dynamic}, ${scope})`; } } if (block) { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 93bd8c17..4a5f8d20 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -118,12 +118,13 @@ export interface ASTComponent { isDynamic: boolean; dynamicProps: string | null; props: { [name: string]: string }; - slots: { [name: string]: AST }; + slots: { [name: string]: { content: AST; attrs?: { [key: string]: string }; scope?: string } }; } export interface ASTSlot { type: ASTType.TSlot; name: string; + attrs: { [key: string]: string }; defaultContent: AST | null; } @@ -593,7 +594,7 @@ function parseTCall(node: Element, ctx: ParsingContext): AST | null { if (ast && ast.type === ASTType.TComponent) { return { ...ast, - slots: { default: tcall }, + slots: { default: { content: tcall } }, }; } } @@ -741,6 +742,11 @@ function parseComponent(node: Element, ctx: ParsingContext): AST | null { // named slots const slotNodes = Array.from(clone.querySelectorAll("[t-set-slot]")); for (let slotNode of slotNodes) { + if (slotNode.tagName !== "t") { + throw new Error( + `Directive 't-set-slot' can only be used on nodes (used on a <${slotNode.tagName}>)` + ); + } const name = slotNode.getAttribute("t-set-slot")!; // check if this is defined in a sub component (in which case it should @@ -762,14 +768,27 @@ function parseComponent(node: Element, ctx: ParsingContext): AST | null { slotNode.remove(); const slotAst = parseNode(slotNode, ctx); if (slotAst) { - slots[name] = slotAst; + const slotInfo: any = { content: slotAst }; + const attrs: { [key: string]: string } = {}; + for (let attributeName of slotNode.getAttributeNames()) { + const value = slotNode.getAttribute(attributeName)!; + if (attributeName === "t-slot-scope") { + slotInfo.scope = value; + continue; + } + attrs[attributeName] = value; + } + if (Object.keys(attrs).length) { + slotInfo.attrs = attrs; + } + slots[name] = slotInfo; } } // default slot const defaultContent = parseChildNodes(clone, ctx); if (defaultContent) { - slots.default = defaultContent; + slots.default = { content: defaultContent }; } } return { type: ASTType.TComponent, name, isDynamic, dynamicProps, props, slots }; @@ -783,9 +802,17 @@ function parseTSlot(node: Element, ctx: ParsingContext): AST | null { if (!node.hasAttribute("t-slot")) { return null; } + const name = node.getAttribute("t-slot")!; + node.removeAttribute("t-slot"); + const attrs: { [key: string]: string } = {}; + for (let attributeName of node.getAttributeNames()) { + const value = node.getAttribute(attributeName)!; + attrs[attributeName] = value; + } return { type: ASTType.TSlot, - name: node.getAttribute("t-slot")!, + name, + attrs, defaultContent: parseChildNodes(node, ctx), }; } diff --git a/src/component/component_node.ts b/src/component/component_node.ts index 897b4c4d..749df4f4 100644 --- a/src/component/component_node.ts +++ b/src/component/component_node.ts @@ -87,7 +87,6 @@ export class ComponentNode level: number; childEnv: Env; children: { [key: string]: ComponentNode } = Object.create(null); - slots: any = {}; refs: any = {}; willStart: LifecycleHook[] = []; diff --git a/src/memo.ts b/src/memo.ts index eebded18..2a51b966 100644 --- a/src/memo.ts +++ b/src/memo.ts @@ -39,7 +39,7 @@ export class Memo extends Component { */ function shallowEqual(p1: any, p2: any): boolean { for (let k in p1) { - if (p1[k] !== p2[k]) { + if (k !== "slots" && p1[k] !== p2[k]) { return false; } } diff --git a/tests/compiler/parser.test.ts b/tests/compiler/parser.test.ts index e2cee68a..1e46cdcc 100644 --- a/tests/compiler/parser.test.ts +++ b/tests/compiler/parser.test.ts @@ -1080,7 +1080,22 @@ describe("qweb parser", () => { dynamicProps: null, props: {}, isDynamic: false, - slots: { default: { type: ASTType.Text, value: "foo" } }, + slots: { default: { content: { type: ASTType.Text, value: "foo" } } }, + }); + }); + + test("a component with a default slot with attributes", async () => { + expect( + parse(`foo`) + ).toEqual({ + type: ASTType.TComponent, + name: "MyComponent", + dynamicProps: null, + props: {}, + isDynamic: false, + slots: { + default: { content: { type: ASTType.Text, value: "foo" }, attrs: { param: "param" } }, + }, }); }); @@ -1093,31 +1108,33 @@ describe("qweb parser", () => { props: {}, slots: { default: { - type: ASTType.Multi, - content: [ - { - type: ASTType.DomNode, - tag: "span", - dynamicTag: null, - attrs: {}, - content: [], - ref: null, - model: null, - on: {}, - ns: null, - }, - { - type: ASTType.DomNode, - tag: "div", - dynamicTag: null, - attrs: {}, - content: [], - ref: null, - model: null, - on: {}, - ns: null, - }, - ], + content: { + type: ASTType.Multi, + content: [ + { + type: ASTType.DomNode, + tag: "span", + dynamicTag: null, + attrs: {}, + content: [], + ref: null, + model: null, + on: {}, + ns: null, + }, + { + type: ASTType.DomNode, + tag: "div", + dynamicTag: null, + attrs: {}, + content: [], + ref: null, + model: null, + on: {}, + ns: null, + }, + ], + }, }, }, }); @@ -1130,10 +1147,27 @@ describe("qweb parser", () => { isDynamic: false, dynamicProps: null, props: {}, - slots: { name: { type: ASTType.Text, value: "foo" } }, + slots: { name: { content: { type: ASTType.Text, value: "foo" } } }, }); }); + test("a component with a named slot with attributes", async () => { + expect(parse(`foo`)).toEqual({ + type: ASTType.TComponent, + name: "MyComponent", + isDynamic: false, + dynamicProps: null, + props: {}, + slots: { name: { content: { type: ASTType.Text, value: "foo" }, attrs: { param: "param" } } }, + }); + }); + + test("a component with a named slot with div tag", async () => { + expect(() => + parse(`
foo
`) + ).toThrowError(); + }); + test("a component with a named slot and some white space", async () => { expect(parse(`foo `)).toEqual({ type: ASTType.TComponent, @@ -1142,8 +1176,8 @@ describe("qweb parser", () => { props: {}, isDynamic: false, slots: { - default: { type: ASTType.Text, value: " " }, - name: { type: ASTType.Text, value: "foo" }, + default: { content: { type: ASTType.Text, value: " " } }, + name: { content: { type: ASTType.Text, value: "foo" } }, }, }); }); @@ -1161,8 +1195,8 @@ describe("qweb parser", () => { props: {}, isDynamic: false, slots: { - a: { type: ASTType.Text, value: "foo" }, - b: { type: ASTType.Text, value: "bar" }, + a: { content: { type: ASTType.Text, value: "foo" } }, + b: { content: { type: ASTType.Text, value: "bar" } }, }, }); }); @@ -1213,7 +1247,7 @@ describe("qweb parser", () => { dynamicProps: null, props: {}, isDynamic: false, - slots: { default: { body: null, name: "subTemplate", type: ASTType.TCall } }, + slots: { default: { content: { body: null, name: "subTemplate", type: ASTType.TCall } } }, }); }); @@ -1233,12 +1267,14 @@ describe("qweb parser", () => { isDynamic: false, slots: { default: { - type: ASTType.TComponent, - isDynamic: false, - name: "Child", - dynamicProps: null, - props: {}, - slots: { brol: { type: ASTType.Text, value: "coucou" } }, + content: { + type: ASTType.TComponent, + isDynamic: false, + name: "Child", + dynamicProps: null, + props: {}, + slots: { brol: { content: { type: ASTType.Text, value: "coucou" } } }, + }, }, }, }); @@ -1248,7 +1284,7 @@ describe("qweb parser", () => { const template = ` - coucou + coucou `; @@ -1260,12 +1296,14 @@ describe("qweb parser", () => { isDynamic: false, slots: { default: { - type: ASTType.TComponent, - isDynamic: false, - name: "Child", - dynamicProps: null, - props: {}, - slots: { brol: { type: ASTType.Text, value: "coucou" } }, + content: { + type: ASTType.TComponent, + isDynamic: false, + name: "Child", + dynamicProps: null, + props: {}, + slots: { brol: { content: { type: ASTType.Text, value: "coucou" } } }, + }, }, }, }); @@ -1279,6 +1317,7 @@ describe("qweb parser", () => { expect(parse(``)).toEqual({ type: ASTType.TSlot, name: "default", + attrs: {}, defaultContent: null, }); }); @@ -1287,6 +1326,7 @@ describe("qweb parser", () => { expect(parse(`default content`)).toEqual({ type: ASTType.TSlot, name: "header", + attrs: {}, defaultContent: { type: ASTType.Text, value: "default content" }, }); }); diff --git a/tests/components/__snapshots__/error_handling.test.ts.snap b/tests/components/__snapshots__/error_handling.test.ts.snap index 30916e66..745a9d6b 100644 --- a/tests/components/__snapshots__/error_handling.test.ts.snap +++ b/tests/components/__snapshots__/error_handling.test.ts.snap @@ -105,7 +105,7 @@ exports[`can catch errors can catch an error in a component render function 2`] if (ctx['state'].error) { b2 = text(\`Error handled\`); } else { - b3 = callSlot(ctx, node, key, 'default'); + b3 = callSlot(ctx, node, key, 'default', false, {}); } return block1([], [b2, b3]); } @@ -117,16 +117,15 @@ exports[`can catch errors can catch an error in a component render function 3`] ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); - const slot2 = ctx => (node, key) => { - return component(\`ErrorComponent\`, {flag: ctx['state'].flag}, key + \`__3\`, node, ctx); + const slot1 = (ctx, node, key) => { + return component(\`ErrorComponent\`, {flag: ctx['state'].flag}, key + \`__2\`, node, ctx); } return function template(ctx, node, key = \\"\\") { - let b3 = assign(component(\`ErrorBoundary\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`ErrorBoundary\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__3\`, node, ctx); return block1([], [b3]); } }" @@ -159,7 +158,7 @@ exports[`can catch errors can catch an error in the constructor call of a compon if (ctx['state'].error) { b2 = text(\`Error handled\`); } else { - b3 = callSlot(ctx, node, key, 'default'); + b3 = callSlot(ctx, node, key, 'default', false, {}); } return block1([], [b2, b3]); } @@ -207,7 +206,7 @@ exports[`can catch errors can catch an error in the constructor call of a compon if (ctx['state'].error) { b2 = text(\`Error handled\`); } else { - b3 = callSlot(ctx, node, key, 'default'); + b3 = callSlot(ctx, node, key, 'default', false, {}); } return block1([], [b2, b3]); } @@ -219,18 +218,17 @@ exports[`can catch errors can catch an error in the constructor call of a compon ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); - const slot2 = ctx => (node, key) => { - let b3 = component(\`ClassicCompoent\`, {}, key + \`__3\`, node, ctx); - let b4 = component(\`ErrorComponent\`, {}, key + \`__4\`, node, ctx); + const slot1 = (ctx, node, key) => { + let b3 = component(\`ClassicCompoent\`, {}, key + \`__2\`, node, ctx); + let b4 = component(\`ErrorComponent\`, {}, key + \`__3\`, node, ctx); return multi([b3, b4]); } return function template(ctx, node, key = \\"\\") { - let b5 = assign(component(\`ErrorBoundary\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b5 = component(\`ErrorBoundary\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__4\`, node, ctx); return block1([], [b5]); } }" @@ -241,16 +239,15 @@ exports[`can catch errors can catch an error in the constructor call of a compon ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); - const slot2 = ctx => (node, key) => { - return component(\`ErrorComponent\`, {}, key + \`__3\`, node, ctx); + const slot1 = (ctx, node, key) => { + return component(\`ErrorComponent\`, {}, key + \`__2\`, node, ctx); } return function template(ctx, node, key = \\"\\") { - let b3 = assign(component(\`ErrorBoundary\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`ErrorBoundary\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__3\`, node, ctx); return block1([], [b3]); } }" @@ -284,7 +281,7 @@ exports[`can catch errors can catch an error in the initial call of a component if (ctx['state'].error) { b2 = text(\`Error handled\`); } else { - b3 = callSlot(ctx, node, key, 'default'); + b3 = callSlot(ctx, node, key, 'default', false, {}); } return block1([], [b2, b3]); } @@ -296,16 +293,15 @@ exports[`can catch errors can catch an error in the initial call of a component ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); - const slot2 = ctx => (node, key) => { - return component(\`ErrorComponent\`, {}, key + \`__3\`, node, ctx); + const slot1 = (ctx, node, key) => { + return component(\`ErrorComponent\`, {}, key + \`__2\`, node, ctx); } return function template(ctx, node, key = \\"\\") { - let b3 = assign(component(\`ErrorBoundary\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`ErrorBoundary\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__3\`, node, ctx); return block1([], [b3]); } }" @@ -339,7 +335,7 @@ exports[`can catch errors can catch an error in the initial call of a component if (ctx['state'].error) { b2 = text(\`Error handled\`); } else { - b3 = callSlot(ctx, node, key, 'default'); + b3 = callSlot(ctx, node, key, 'default', false, {}); } return block1([], [b2, b3]); } @@ -351,18 +347,17 @@ exports[`can catch errors can catch an error in the initial call of a component ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); - const slot2 = ctx => (node, key) => { - return component(\`ErrorComponent\`, {}, key + \`__3\`, node, ctx); + const slot1 = (ctx, node, key) => { + return component(\`ErrorComponent\`, {}, key + \`__2\`, node, ctx); } return function template(ctx, node, key = \\"\\") { let b3; if (ctx['state'].flag) { - b3 = assign(component(\`ErrorBoundary\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + b3 = component(\`ErrorBoundary\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__3\`, node, ctx); } return block1([], [b3]); } @@ -396,7 +391,7 @@ exports[`can catch errors can catch an error in the mounted call 2`] = ` if (ctx['state'].error) { b2 = text(\`Error handled\`); } else { - b3 = callSlot(ctx, node, key, 'default'); + b3 = callSlot(ctx, node, key, 'default', false, {}); } return block1([], [b2, b3]); } @@ -408,16 +403,15 @@ exports[`can catch errors can catch an error in the mounted call 3`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); - const slot2 = ctx => (node, key) => { - return component(\`ErrorComponent\`, {}, key + \`__3\`, node, ctx); + const slot1 = (ctx, node, key) => { + return component(\`ErrorComponent\`, {}, key + \`__2\`, node, ctx); } return function template(ctx, node, key = \\"\\") { - let b3 = assign(component(\`ErrorBoundary\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`ErrorBoundary\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__3\`, node, ctx); return block1([], [b3]); } }" @@ -451,7 +445,7 @@ exports[`can catch errors can catch an error in the willPatch call 2`] = ` if (ctx['state'].error) { b2 = text(\`Error handled\`); } else { - b3 = callSlot(ctx, node, key, 'default'); + b3 = callSlot(ctx, node, key, 'default', false, {}); } return block1([], [b2, b3]); } @@ -463,17 +457,16 @@ exports[`can catch errors can catch an error in the willPatch call 3`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); - const slot2 = ctx => (node, key) => { - return component(\`ErrorComponent\`, {message: ctx['state'].message}, key + \`__3\`, node, ctx); + const slot1 = (ctx, node, key) => { + return component(\`ErrorComponent\`, {message: ctx['state'].message}, key + \`__2\`, node, ctx); } return function template(ctx, node, key = \\"\\") { let d1 = ctx['state'].message; - let b3 = assign(component(\`ErrorBoundary\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`ErrorBoundary\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__3\`, node, ctx); return block1([d1], [b3]); } }" @@ -506,7 +499,7 @@ exports[`can catch errors can catch an error in the willStart call 2`] = ` if (ctx['state'].error) { b2 = text(\`Error handled\`); } else { - b3 = callSlot(ctx, node, key, 'default'); + b3 = callSlot(ctx, node, key, 'default', false, {}); } return block1([], [b2, b3]); } @@ -518,16 +511,15 @@ exports[`can catch errors can catch an error in the willStart call 3`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); - const slot2 = ctx => (node, key) => { - return component(\`ErrorComponent\`, {}, key + \`__3\`, node, ctx); + const slot1 = (ctx, node, key) => { + return component(\`ErrorComponent\`, {}, key + \`__2\`, node, ctx); } return function template(ctx, node, key = \\"\\") { - let b3 = assign(component(\`ErrorBoundary\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`ErrorBoundary\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__3\`, node, ctx); return block1([], [b3]); } }" @@ -574,7 +566,7 @@ exports[`can catch errors can catch an error origination from a child's willStar if (ctx['state'].error) { b2 = text(\`Error handled\`); } else { - b3 = callSlot(ctx, node, key, 'default'); + b3 = callSlot(ctx, node, key, 'default', false, {}); } return block1([], [b2, b3]); } @@ -586,18 +578,17 @@ exports[`can catch errors can catch an error origination from a child's willStar ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); - const slot2 = ctx => (node, key) => { - let b3 = component(\`ClassicCompoent\`, {}, key + \`__3\`, node, ctx); - let b4 = component(\`ErrorComponent\`, {}, key + \`__4\`, node, ctx); + const slot1 = (ctx, node, key) => { + let b3 = component(\`ClassicCompoent\`, {}, key + \`__2\`, node, ctx); + let b4 = component(\`ErrorComponent\`, {}, key + \`__3\`, node, ctx); return multi([b3, b4]); } return function template(ctx, node, key = \\"\\") { - let b5 = assign(component(\`ErrorBoundary\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b5 = component(\`ErrorBoundary\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__4\`, node, ctx); return block1([], [b5]); } }" diff --git a/tests/components/__snapshots__/props_validation.test.ts.snap b/tests/components/__snapshots__/props_validation.test.ts.snap index 0e79005d..fa9ff3a7 100644 --- a/tests/components/__snapshots__/props_validation.test.ts.snap +++ b/tests/components/__snapshots__/props_validation.test.ts.snap @@ -9,9 +9,9 @@ exports[`default props can set default required boolean values 1`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -26,9 +26,9 @@ exports[`default props can set default values 1`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -43,9 +43,9 @@ exports[`default props default values are also set whenever component is updated let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['state'].p} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['state'].p} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -60,9 +60,9 @@ exports[`props validation can validate a prop with multiple types 1`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['p']} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['p']} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -77,9 +77,9 @@ exports[`props validation can validate a prop with multiple types 2`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['p']} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['p']} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -94,9 +94,9 @@ exports[`props validation can validate an array with given primitive type 1`] = let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['p']} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['p']} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -111,9 +111,9 @@ exports[`props validation can validate an array with given primitive type 2`] = let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['p']} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['p']} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -128,9 +128,9 @@ exports[`props validation can validate an array with multiple sub element types let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['p']} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['p']} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -145,9 +145,9 @@ exports[`props validation can validate an array with multiple sub element types let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['p']} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['p']} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -162,9 +162,9 @@ exports[`props validation can validate an array with multiple sub element types let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['p']} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['p']} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -179,9 +179,9 @@ exports[`props validation can validate an object with simple shape 1`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['p']} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['p']} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -196,9 +196,9 @@ exports[`props validation can validate an optional props 1`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['p']} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['p']} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -213,9 +213,9 @@ exports[`props validation can validate an optional props 2`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['p']} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['p']} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -230,9 +230,9 @@ exports[`props validation can validate recursively complicated prop def 1`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['p']} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['p']} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -247,9 +247,9 @@ exports[`props validation can validate recursively complicated prop def 2`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['p']} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['p']} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -264,9 +264,9 @@ exports[`props validation default values are applied before validating props at let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['state'].p} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['state'].p} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -281,9 +281,9 @@ exports[`props validation props are validated in dev mode (code snapshot) 1`] = let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {message: 1} - helpers.validateProps(\`Child\`, props2, ctx) - let b2 = component(\`Child\`, props2, key + \`__1\`, node, ctx); + const props1 = {message: 1} + helpers.validateProps(\`Child\`, props1, ctx) + let b2 = component(\`Child\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -298,9 +298,9 @@ exports[`props validation props are validated whenever component is updated 1`] let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['state'].p} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['state'].p} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -315,9 +315,9 @@ exports[`props validation validate simple types 1`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['p']} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['p']} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -332,9 +332,9 @@ exports[`props validation validate simple types 2`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['p']} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['p']} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -349,9 +349,9 @@ exports[`props validation validate simple types 3`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['p']} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['p']} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -366,9 +366,9 @@ exports[`props validation validate simple types 4`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['p']} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['p']} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -383,9 +383,9 @@ exports[`props validation validate simple types 5`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['p']} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['p']} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -400,9 +400,9 @@ exports[`props validation validate simple types 6`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['p']} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['p']} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -417,9 +417,9 @@ exports[`props validation validate simple types, alternate form 1`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['p']} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['p']} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -434,9 +434,9 @@ exports[`props validation validate simple types, alternate form 2`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['p']} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['p']} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -451,9 +451,9 @@ exports[`props validation validate simple types, alternate form 3`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['p']} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['p']} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -468,9 +468,9 @@ exports[`props validation validate simple types, alternate form 4`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['p']} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['p']} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -485,9 +485,9 @@ exports[`props validation validate simple types, alternate form 5`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['p']} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['p']} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" @@ -502,9 +502,9 @@ exports[`props validation validate simple types, alternate form 6`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - const props2 = {p: ctx['p']} - helpers.validateProps(\`SubComp\`, props2, ctx) - let b2 = component(\`SubComp\`, props2, key + \`__1\`, node, ctx); + const props1 = {p: ctx['p']} + helpers.validateProps(\`SubComp\`, props1, ctx) + let b2 = component(\`SubComp\`, props1, key + \`__2\`, node, ctx); return block1([], [b2]); } }" diff --git a/tests/components/__snapshots__/refs.test.ts.snap b/tests/components/__snapshots__/refs.test.ts.snap index 1b82bb18..29af2931 100644 --- a/tests/components/__snapshots__/refs.test.ts.snap +++ b/tests/components/__snapshots__/refs.test.ts.snap @@ -25,7 +25,7 @@ exports[`refs refs are properly bound in slots 1`] = ` let block1 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'footer'); + let b2 = callSlot(ctx, node, key, 'footer', false, {}); return block1([], [b2]); } }" @@ -36,12 +36,11 @@ exports[`refs refs are properly bound in slots 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); let block2 = createBlock(\`\`); - const slot3 = ctx => (node, key) => { + const slot2 = (ctx, node, key) => { const refs = ctx.__owl__.refs let d2 = [ctx['doSomething'], ctx]; let d3 = (el) => refs[\`myButton\`] = el; @@ -51,8 +50,8 @@ exports[`refs refs are properly bound in slots 2`] = ` return function template(ctx, node, key = \\"\\") { const refs = ctx.__owl__.refs; let d1 = ctx['state'].val; - const ctx2 = capture(ctx); - let b3 = assign(component(\`Dialog\`, {}, key + \`__1\`, node, ctx), {slots: {'footer': slot3(ctx2)}}); + const ctx1 = capture(ctx); + let b3 = component(\`Dialog\`, {slots: {'footer': {__render: slot2, __ctx: ctx1}}}, key + \`__3\`, node, ctx); return block1([d1], [b3]); } }" diff --git a/tests/components/__snapshots__/slots.test.ts.snap b/tests/components/__snapshots__/slots.test.ts.snap index 0b17a161..b1c8c4a9 100644 --- a/tests/components/__snapshots__/slots.test.ts.snap +++ b/tests/components/__snapshots__/slots.test.ts.snap @@ -9,8 +9,8 @@ exports[`slots can define and call slots 1`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'header'); - let b3 = callSlot(ctx, node, key, 'footer'); + let b2 = callSlot(ctx, node, key, 'header', false, {}); + let b3 = callSlot(ctx, node, key, 'footer', false, {}); return block1([], [b2, b3]); } }" @@ -21,23 +21,66 @@ exports[`slots can define and call slots 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); let block2 = createBlock(\`header\`); let block3 = createBlock(\`footer\`); - const slot3 = ctx => (node, key) => { + const slot2 = (ctx, node, key) => { return block2(); } - const slot4 = ctx => (node, key) => { + const slot3 = (ctx, node, key) => { return block3(); } return function template(ctx, node, key = \\"\\") { - const ctx2 = capture(ctx); - let b4 = assign(component(\`Dialog\`, {}, key + \`__1\`, node, ctx), {slots: {'header': slot3(ctx2), 'footer': slot4(ctx2)}}); + const ctx1 = capture(ctx); + let b4 = component(\`Dialog\`, {slots: {'header': {__render: slot2, __ctx: ctx1}, 'footer': {__render: slot3, __ctx: ctx1}}}, key + \`__4\`, node, ctx); + return block1([], [b4]); + } +}" +`; + +exports[`slots can define and call slots with params 1`] = ` +"function anonymous(bdom, helpers +) { + let { text, createBlock, list, multi, html, toggler, component } = bdom; + let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; + + let block1 = createBlock(\`
\`); + + return function template(ctx, node, key = \\"\\") { + let d1 = ctx['props'].slots['header'].param; + let b2 = callSlot(ctx, node, key, 'header', false, {}); + let d2 = ctx['props'].slots['footer'].param; + let b3 = callSlot(ctx, node, key, 'footer', false, {}); + return block1([d1, d2], [b2, b3]); + } +}" +`; + +exports[`slots can define and call slots with params 2`] = ` +"function anonymous(bdom, helpers +) { + let { text, createBlock, list, multi, html, toggler, component } = bdom; + let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; + + let block1 = createBlock(\`
\`); + let block2 = createBlock(\`header\`); + let block3 = createBlock(\`footer\`); + + const slot2 = (ctx, node, key) => { + return block2(); + } + + const slot3 = (ctx, node, key) => { + return block3(); + } + + return function template(ctx, node, key = \\"\\") { + const ctx1 = capture(ctx); + let b4 = component(\`Dialog\`, {slots: {'header': {__render: slot2, __ctx: ctx1, param: ctx['var']}, 'footer': {__render: slot3, __ctx: ctx1, param: '5'}}}, key + \`__4\`, node, ctx); return block1([], [b4]); } }" @@ -50,7 +93,7 @@ exports[`slots can render node with t-ref and Component in same slot 1`] = ` let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; return function template(ctx, node, key = \\"\\") { - return callSlot(ctx, node, key, 'default'); + return callSlot(ctx, node, key, 'default', false, {}); } }" `; @@ -60,21 +103,20 @@ exports[`slots can render node with t-ref and Component in same slot 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block2 = createBlock(\`
\`); - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { const refs = ctx.__owl__.refs let d1 = (el) => refs[\`div\`] = el; let b2 = block2([d1]); - let b3 = component(\`Child\`, {}, key + \`__3\`, node, ctx); + let b3 = component(\`Child\`, {}, key + \`__2\`, node, ctx); return multi([b2, b3]); } return function template(ctx, node, key = \\"\\") { const refs = ctx.__owl__.refs; - return assign(component(\`Child\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + return component(\`Child\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__3\`, node, ctx); } }" `; @@ -86,7 +128,7 @@ exports[`slots can render only empty slot 1`] = ` let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; return function template(ctx, node, key = \\"\\") { - return callSlot(ctx, node, key, 'default'); + return callSlot(ctx, node, key, 'default', false, {}); } }" `; @@ -98,7 +140,7 @@ exports[`slots content is the default slot (variation) 1`] = ` let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; return function template(ctx, node, key = \\"\\") { - return callSlot(ctx, node, key, 'default'); + return callSlot(ctx, node, key, 'default', false, {}); } }" `; @@ -108,16 +150,15 @@ exports[`slots content is the default slot (variation) 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`sts rocks\`); - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { return block1(); } return function template(ctx, node, key = \\"\\") { - return assign(component(\`Dialog\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + return component(\`Dialog\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); } }" `; @@ -131,7 +172,7 @@ exports[`slots content is the default slot 1`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([], [b2]); } }" @@ -142,17 +183,16 @@ exports[`slots content is the default slot 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); let block2 = createBlock(\`sts rocks\`); - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { return block2(); } return function template(ctx, node, key = \\"\\") { - let b3 = assign(component(\`Dialog\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`Dialog\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); return block1([], [b3]); } }" @@ -171,7 +211,7 @@ exports[`slots dafault slots can define a default content 1`] = ` } return function template(ctx, node, key = \\"\\") { - let b3 = callSlot(ctx, node, key, 'default', defaultSlot1, false); + let b3 = callSlot(ctx, node, key, 'default', false, {}, defaultSlot1); return block1([], [b3]); } }" @@ -205,7 +245,7 @@ exports[`slots default content is not rendered if named slot is provided 1`] = ` } return function template(ctx, node, key = \\"\\") { - let b3 = callSlot(ctx, node, key, 'header', defaultSlot1, false); + let b3 = callSlot(ctx, node, key, 'header', false, {}, defaultSlot1); return block1([], [b3]); } }" @@ -216,17 +256,16 @@ exports[`slots default content is not rendered if named slot is provided 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); - const slot3 = ctx => (node, key) => { + const slot2 = (ctx, node, key) => { return text(\`hey\`); } return function template(ctx, node, key = \\"\\") { - const ctx2 = capture(ctx); - let b3 = assign(component(\`Dialog\`, {}, key + \`__1\`, node, ctx), {slots: {'header': slot3(ctx2)}}); + const ctx1 = capture(ctx); + let b3 = component(\`Dialog\`, {slots: {'header': {__render: slot2, __ctx: ctx1}}}, key + \`__3\`, node, ctx); return block1([], [b3]); } }" @@ -245,7 +284,7 @@ exports[`slots default content is not rendered if slot is provided 1`] = ` } return function template(ctx, node, key = \\"\\") { - let b3 = callSlot(ctx, node, key, 'default', defaultSlot1, false); + let b3 = callSlot(ctx, node, key, 'default', false, {}, defaultSlot1); return block1([], [b3]); } }" @@ -256,16 +295,15 @@ exports[`slots default content is not rendered if slot is provided 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { return text(\`hey\`); } return function template(ctx, node, key = \\"\\") { - let b3 = assign(component(\`Dialog\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`Dialog\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); return block1([], [b3]); } }" @@ -288,8 +326,8 @@ exports[`slots default slot next to named slot, with default content 1`] = ` } return function template(ctx, node, key = \\"\\") { - let b3 = callSlot(ctx, node, key, 'default', defaultSlot1, false); - let b5 = callSlot(ctx, node, key, 'footer', defaultSlot2, false); + let b3 = callSlot(ctx, node, key, 'default', false, {}, defaultSlot1); + let b5 = callSlot(ctx, node, key, 'footer', false, {}, defaultSlot2); return block1([], [b3, b5]); } }" @@ -300,17 +338,16 @@ exports[`slots default slot next to named slot, with default content 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); - const slot3 = ctx => (node, key) => { + const slot2 = (ctx, node, key) => { return text(\` Overridden footer \`); } return function template(ctx, node, key = \\"\\") { - const ctx2 = capture(ctx); - let b3 = assign(component(\`Dialog\`, {}, key + \`__1\`, node, ctx), {slots: {'footer': slot3(ctx2)}}); + const ctx1 = capture(ctx); + let b3 = component(\`Dialog\`, {slots: {'footer': {__render: slot2, __ctx: ctx1}}}, key + \`__3\`, node, ctx); return block1([], [b3]); } }" @@ -323,7 +360,7 @@ exports[`slots default slot work with text nodes (variation) 1`] = ` let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; return function template(ctx, node, key = \\"\\") { - return callSlot(ctx, node, key, 'default'); + return callSlot(ctx, node, key, 'default', false, {}); } }" `; @@ -333,14 +370,13 @@ exports[`slots default slot work with text nodes (variation) 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { return text(\`sts rocks\`); } return function template(ctx, node, key = \\"\\") { - return assign(component(\`Dialog\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + return component(\`Dialog\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); } }" `; @@ -354,7 +390,7 @@ exports[`slots default slot work with text nodes 1`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([], [b2]); } }" @@ -365,16 +401,15 @@ exports[`slots default slot work with text nodes 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { return text(\`sts rocks\`); } return function template(ctx, node, key = \\"\\") { - let b3 = assign(component(\`Dialog\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`Dialog\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); return block1([], [b3]); } }" @@ -391,7 +426,7 @@ exports[`slots dynamic t-slot call 1`] = ` return function template(ctx, node, key = \\"\\") { let d1 = [ctx['toggle'], ctx]; const slot1 = (ctx['current'].slot); - let b2 = toggler(slot1, callSlot(ctx, node, key, slot1)); + let b2 = toggler(slot1, callSlot(ctx, node, key, slot1), true, {}); return block1([d1], [b2]); } }" @@ -402,26 +437,25 @@ exports[`slots dynamic t-slot call 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); let block3 = createBlock(\`

slot1

\`); let block4 = createBlock(\`content\`); let block5 = createBlock(\`

slot2

\`); - const slot3 = ctx => (node, key) => { + const slot2 = (ctx, node, key) => { let b3 = block3(); let b4 = block4(); return multi([b3, b4]); } - const slot4 = ctx => (node, key) => { + const slot3 = (ctx, node, key) => { return block5(); } return function template(ctx, node, key = \\"\\") { - const ctx2 = capture(ctx); - let b6 = assign(component(\`Toggler\`, {}, key + \`__1\`, node, ctx), {slots: {'slot1': slot3(ctx2), 'slot2': slot4(ctx2)}}); + const ctx1 = capture(ctx); + let b6 = component(\`Toggler\`, {slots: {'slot1': {__render: slot2, __ctx: ctx1}, 'slot2': {__render: slot3, __ctx: ctx1}}}, key + \`__4\`, node, ctx); return block1([], [b6]); } }" @@ -441,7 +475,7 @@ exports[`slots dynamic t-slot call with default 1`] = ` return function template(ctx, node, key = \\"\\") { let d1 = [ctx['toggle'], ctx]; - let b3 = callSlot(ctx, node, key, (ctx['current'].slot), defaultSlot1, true); + let b3 = callSlot(ctx, node, key, (ctx['current'].slot), true, {}, defaultSlot1); return block1([d1], [b3]); } }" @@ -452,26 +486,25 @@ exports[`slots dynamic t-slot call with default 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); let block3 = createBlock(\`

slot1

\`); let block4 = createBlock(\`content\`); let block5 = createBlock(\`

slot2

\`); - const slot3 = ctx => (node, key) => { + const slot2 = (ctx, node, key) => { let b3 = block3(); let b4 = block4(); return multi([b3, b4]); } - const slot4 = ctx => (node, key) => { + const slot3 = (ctx, node, key) => { return block5(); } return function template(ctx, node, key = \\"\\") { - const ctx2 = capture(ctx); - let b6 = assign(component(\`Toggler\`, {}, key + \`__1\`, node, ctx), {slots: {'slot1': slot3(ctx2), 'slot2': slot4(ctx2)}}); + const ctx1 = capture(ctx); + let b6 = component(\`Toggler\`, {slots: {'slot1': {__render: slot2, __ctx: ctx1}, 'slot2': {__render: slot3, __ctx: ctx1}}}, key + \`__4\`, node, ctx); return block1([], [b6]); } }" @@ -484,8 +517,8 @@ exports[`slots fun: two calls to the same slot 1`] = ` let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'default'); - let b3 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); + let b3 = callSlot(ctx, node, key, 'default', false, {}); return multi([b2, b3]); } }" @@ -496,14 +529,13 @@ exports[`slots fun: two calls to the same slot 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { return text(\`some text\`); } return function template(ctx, node, key = \\"\\") { - return assign(component(\`Child\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + return component(\`Child\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); } }" `; @@ -517,8 +549,8 @@ exports[`slots missing slots are ignored 1`] = ` let block1 = createBlock(\`some content\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'default'); - let b3 = callSlot(ctx, node, key, 'footer'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); + let b3 = callSlot(ctx, node, key, 'footer', false, {}); return block1([], [b2, b3]); } }" @@ -548,7 +580,7 @@ exports[`slots multiple roots are allowed in a default slot 1`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([], [b2]); } }" @@ -559,20 +591,19 @@ exports[`slots multiple roots are allowed in a default slot 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); let block3 = createBlock(\`sts\`); let block4 = createBlock(\`rocks\`); - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { let b3 = block3(); let b4 = block4(); return multi([b3, b4]); } return function template(ctx, node, key = \\"\\") { - let b5 = assign(component(\`Dialog\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b5 = component(\`Dialog\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); return block1([], [b5]); } }" @@ -587,7 +618,7 @@ exports[`slots multiple roots are allowed in a named slot 1`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'content'); + let b2 = callSlot(ctx, node, key, 'content', false, {}); return block1([], [b2]); } }" @@ -598,21 +629,20 @@ exports[`slots multiple roots are allowed in a named slot 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); let block3 = createBlock(\`sts\`); let block4 = createBlock(\`rocks\`); - const slot3 = ctx => (node, key) => { + const slot2 = (ctx, node, key) => { let b3 = block3(); let b4 = block4(); return multi([b3, b4]); } return function template(ctx, node, key = \\"\\") { - const ctx2 = capture(ctx); - let b5 = assign(component(\`Dialog\`, {}, key + \`__1\`, node, ctx), {slots: {'content': slot3(ctx2)}}); + const ctx1 = capture(ctx); + let b5 = component(\`Dialog\`, {slots: {'content': {__render: slot2, __ctx: ctx1}}}, key + \`__3\`, node, ctx); return block1([], [b5]); } }" @@ -642,8 +672,8 @@ exports[`slots multiple slots containing components 2`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 's1'); - let b3 = callSlot(ctx, node, key, 's2'); + let b2 = callSlot(ctx, node, key, 's1', false, {}); + let b3 = callSlot(ctx, node, key, 's2', false, {}); return block1([], [b2, b3]); } }" @@ -654,19 +684,18 @@ exports[`slots multiple slots containing components 3`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; - const slot3 = ctx => (node, key) => { - return component(\`C\`, {val: 1}, key + \`__4\`, node, ctx); + const slot2 = (ctx, node, key) => { + return component(\`C\`, {val: 1}, key + \`__3\`, node, ctx); } - const slot5 = ctx => (node, key) => { - return component(\`C\`, {val: 2}, key + \`__6\`, node, ctx); + const slot4 = (ctx, node, key) => { + return component(\`C\`, {val: 2}, key + \`__5\`, node, ctx); } return function template(ctx, node, key = \\"\\") { - const ctx2 = capture(ctx); - return assign(component(\`B\`, {}, key + \`__1\`, node, ctx), {slots: {'s1': slot3(ctx2), 's2': slot5(ctx2)}}); + const ctx1 = capture(ctx); + return component(\`B\`, {slots: {'s1': {__render: slot2, __ctx: ctx1}, 's2': {__render: slot4, __ctx: ctx1}}}, key + \`__6\`, node, ctx); } }" `; @@ -680,8 +709,8 @@ exports[`slots named slot inside slot 1`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'brol'); - let b3 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'brol', false, {}); + let b3 = callSlot(ctx, node, key, 'default', false, {}); return block1([], [b2, b3]); } }" @@ -692,30 +721,29 @@ exports[`slots named slot inside slot 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); let block2 = createBlock(\`

A

\`); let block3 = createBlock(\`

B

\`); - const slot3 = ctx => (node, key) => { + const slot2 = (ctx, node, key) => { let d1 = ctx['value']; return block2([d1]); } - const slot4 = ctx => (node, key) => { - const ctx6 = capture(ctx); - return assign(component(\`Child\`, {}, key + \`__5\`, node, ctx), {slots: {'brol': slot7(ctx6)}}); + const slot3 = (ctx, node, key) => { + const ctx4 = capture(ctx); + return component(\`Child\`, {slots: {'brol': {__render: slot5, __ctx: ctx4}}}, key + \`__6\`, node, ctx); } - const slot7 = ctx => (node, key) => { + const slot5 = (ctx, node, key) => { let d2 = ctx['value']; return block3([d2]); } return function template(ctx, node, key = \\"\\") { - const ctx2 = capture(ctx); - let b5 = assign(component(\`Child\`, {}, key + \`__1\`, node, ctx), {slots: {'brol': slot3(ctx2), 'default': slot4(ctx2)}}); + const ctx1 = capture(ctx); + let b5 = component(\`Child\`, {slots: {'brol': {__render: slot2, __ctx: ctx1}, 'default': {__render: slot3, __ctx: ctx1}}}, key + \`__7\`, node, ctx); return block1([], [b5]); } }" @@ -730,8 +758,8 @@ exports[`slots named slot inside slot, part 3 1`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'brol'); - let b3 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'brol', false, {}); + let b3 = callSlot(ctx, node, key, 'default', false, {}); return block1([], [b2, b3]); } }" @@ -742,30 +770,29 @@ exports[`slots named slot inside slot, part 3 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); let block2 = createBlock(\`

A

\`); let block3 = createBlock(\`

B

\`); - const slot3 = ctx => (node, key) => { + const slot2 = (ctx, node, key) => { let d1 = ctx['value']; return block2([d1]); } - const slot4 = ctx => (node, key) => { - const ctx6 = capture(ctx); - return assign(component(\`Child\`, {}, key + \`__5\`, node, ctx), {slots: {'brol': slot7(ctx6)}}); + const slot3 = (ctx, node, key) => { + const ctx4 = capture(ctx); + return component(\`Child\`, {slots: {'brol': {__render: slot5, __ctx: ctx4}}}, key + \`__6\`, node, ctx); } - const slot7 = ctx => (node, key) => { + const slot5 = (ctx, node, key) => { let d2 = ctx['value']; return block3([d2]); } return function template(ctx, node, key = \\"\\") { - const ctx2 = capture(ctx); - let b5 = assign(component(\`Child\`, {}, key + \`__1\`, node, ctx), {slots: {'brol': slot3(ctx2), 'default': slot4(ctx2)}}); + const ctx1 = capture(ctx); + let b5 = component(\`Child\`, {slots: {'brol': {__render: slot2, __ctx: ctx1}, 'default': {__render: slot3, __ctx: ctx1}}}, key + \`__7\`, node, ctx); return block1([], [b5]); } }" @@ -784,7 +811,7 @@ exports[`slots named slots can define a default content 1`] = ` } return function template(ctx, node, key = \\"\\") { - let b3 = callSlot(ctx, node, key, 'header', defaultSlot1, false); + let b3 = callSlot(ctx, node, key, 'header', false, {}, defaultSlot1); return block1([], [b3]); } }" @@ -822,9 +849,9 @@ exports[`slots named slots inside slot, again 1`] = ` } return function template(ctx, node, key = \\"\\") { - let b3 = callSlot(ctx, node, key, 'brol1', defaultSlot1, false); - let b5 = callSlot(ctx, node, key, 'brol2', defaultSlot2, false); - let b6 = callSlot(ctx, node, key, 'default'); + let b3 = callSlot(ctx, node, key, 'brol1', false, {}, defaultSlot1); + let b5 = callSlot(ctx, node, key, 'brol2', false, {}, defaultSlot2); + let b6 = callSlot(ctx, node, key, 'default', false, {}); return block1([], [b3, b5, b6]); } }" @@ -835,30 +862,29 @@ exports[`slots named slots inside slot, again 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); let block2 = createBlock(\`

A

\`); let block3 = createBlock(\`

B

\`); - const slot3 = ctx => (node, key) => { + const slot2 = (ctx, node, key) => { let d1 = ctx['value']; return block2([d1]); } - const slot4 = ctx => (node, key) => { - const ctx6 = capture(ctx); - return assign(component(\`Child\`, {}, key + \`__5\`, node, ctx), {slots: {'brol2': slot7(ctx6)}}); + const slot3 = (ctx, node, key) => { + const ctx4 = capture(ctx); + return component(\`Child\`, {slots: {'brol2': {__render: slot5, __ctx: ctx4}}}, key + \`__6\`, node, ctx); } - const slot7 = ctx => (node, key) => { + const slot5 = (ctx, node, key) => { let d2 = ctx['value']; return block3([d2]); } return function template(ctx, node, key = \\"\\") { - const ctx2 = capture(ctx); - let b5 = assign(component(\`Child\`, {}, key + \`__1\`, node, ctx), {slots: {'brol1': slot3(ctx2), 'default': slot4(ctx2)}}); + const ctx1 = capture(ctx); + let b5 = component(\`Child\`, {slots: {'brol1': {__render: slot2, __ctx: ctx1}, 'default': {__render: slot3, __ctx: ctx1}}}, key + \`__7\`, node, ctx); return block1([], [b5]); } }" @@ -873,7 +899,7 @@ exports[`slots nested slots in same template 1`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([], [b2]); } }" @@ -888,7 +914,7 @@ exports[`slots nested slots in same template 2`] = ` let block1 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([], [b2]); } }" @@ -913,20 +939,19 @@ exports[`slots nested slots in same template 4`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`\`); - const slot2 = ctx => (node, key) => { - return assign(component(\`Child2\`, {}, key + \`__3\`, node, ctx), {slots: {'default': slot4(ctx)}}); + const slot1 = (ctx, node, key) => { + return component(\`Child2\`, {slots: {'default': {__render: slot2, __ctx: ctx}}}, key + \`__4\`, node, ctx); } - const slot4 = ctx => (node, key) => { - return component(\`Child3\`, {}, key + \`__5\`, node, ctx); + const slot2 = (ctx, node, key) => { + return component(\`Child3\`, {}, key + \`__3\`, node, ctx); } return function template(ctx, node, key = \\"\\") { - let b4 = assign(component(\`Child\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b4 = component(\`Child\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__5\`, node, ctx); return block1([], [b4]); } }" @@ -956,7 +981,7 @@ exports[`slots nested slots: evaluation context and parented relationship 2`] = let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([], [b2]); } }" @@ -967,14 +992,13 @@ exports[`slots nested slots: evaluation context and parented relationship 3`] = ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; - const slot2 = ctx => (node, key) => { - return callSlot(ctx, node, key, 'default'); + const slot1 = (ctx, node, key) => { + return callSlot(ctx, node, key, 'default', false, {}); } return function template(ctx, node, key = \\"\\") { - return assign(component(\`GrandChild\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + return component(\`GrandChild\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); } }" `; @@ -984,14 +1008,13 @@ exports[`slots nested slots: evaluation context and parented relationship 4`] = ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; - const slot2 = ctx => (node, key) => { - return component(\`Slot\`, {val: ctx['state'].val}, key + \`__3\`, node, ctx); + const slot1 = (ctx, node, key) => { + return component(\`Slot\`, {val: ctx['state'].val}, key + \`__2\`, node, ctx); } return function template(ctx, node, key = \\"\\") { - return assign(component(\`Child\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + return component(\`Child\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__3\`, node, ctx); } }" `; @@ -1005,7 +1028,7 @@ exports[`slots no named slot content => just no children 1`] = ` let block1 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'header'); + let b2 = callSlot(ctx, node, key, 'header', false, {}); return block1([], [b2]); } }" @@ -1032,7 +1055,7 @@ exports[`slots simple default slot 1`] = ` let block1 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([], [b2]); } }" @@ -1043,14 +1066,88 @@ exports[`slots simple default slot 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { return text(\`some text\`); } return function template(ctx, node, key = \\"\\") { - return assign(component(\`Child\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + return component(\`Child\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); + } +}" +`; + +exports[`slots simple default slot with params 1`] = ` +"function anonymous(bdom, helpers +) { + let { text, createBlock, list, multi, html, toggler, component } = bdom; + let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; + + let block1 = createBlock(\`\`); + + return function template(ctx, node, key = \\"\\") { + let b2 = callSlot(ctx, node, key, 'default', false, {bool: ctx['state'].bool}); + return block1([], [b2]); + } +}" +`; + +exports[`slots simple default slot with params 2`] = ` +"function anonymous(bdom, helpers +) { + let { text, createBlock, list, multi, html, toggler, component } = bdom; + let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; + + const slot2 = (ctx, node, key) => { + let b2,b3; + if (ctx['slotScope'].bool) { + b2 = text(\`some text\`); + } else { + b3 = text(\`other text\`); + } + return multi([b2, b3]); + } + + return function template(ctx, node, key = \\"\\") { + const ctx1 = capture(ctx); + return component(\`Child\`, {slots: {'default': {__render: slot2, __ctx: ctx1, __scope: \\"slotScope\\"}}}, key + \`__3\`, node, ctx); + } +}" +`; + +exports[`slots simple default slot with params 3`] = ` +"function anonymous(bdom, helpers +) { + let { text, createBlock, list, multi, html, toggler, component } = bdom; + let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; + + let block1 = createBlock(\`\`); + + return function template(ctx, node, key = \\"\\") { + let b2 = callSlot(ctx, node, key, 'default', false, {bool: ctx['state'].bool}); + return block1([], [b2]); + } +}" +`; + +exports[`slots simple default slot with params 4`] = ` +"function anonymous(bdom, helpers +) { + let { text, createBlock, list, multi, html, toggler, component } = bdom; + let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; + + const slot1 = (ctx, node, key) => { + let b2,b3; + if (ctx['slotScope'].bool) { + b2 = text(\`some text\`); + } else { + b3 = text(\`other text\`); + } + return multi([b2, b3]); + } + + return function template(ctx, node, key = \\"\\") { + return component(\`Child\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); } }" `; @@ -1062,7 +1159,7 @@ exports[`slots simple default slot, variation 1`] = ` let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; return function template(ctx, node, key = \\"\\") { - return callSlot(ctx, node, key, 'default'); + return callSlot(ctx, node, key, 'default', false, {}); } }" `; @@ -1072,14 +1169,13 @@ exports[`slots simple default slot, variation 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { return text(\`some text\`); } return function template(ctx, node, key = \\"\\") { - return assign(component(\`Child\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + return component(\`Child\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); } }" `; @@ -1107,7 +1203,7 @@ exports[`slots slot and (inline) t-call 2`] = ` let block1 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([], [b2]); } }" @@ -1118,18 +1214,17 @@ exports[`slots slot and (inline) t-call 3`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; - const callTemplate_5 = getTemplate(\`__template__9\`); + const callTemplate_4 = getTemplate(\`__template__9\`); let block1 = createBlock(\`
\`); - const slot3 = ctx => (node, key) => { - return callTemplate_5.call(this, ctx, node, key + \`__4\`); + const slot2 = (ctx, node, key) => { + return callTemplate_4.call(this, ctx, node, key + \`__3\`); } return function template(ctx, node, key = \\"\\") { - const ctx2 = capture(ctx); - let b3 = assign(component(\`Dialog\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot3(ctx2)}}); + const ctx1 = capture(ctx); + let b3 = component(\`Dialog\`, {slots: {'default': {__render: slot2, __ctx: ctx1}}}, key + \`__5\`, node, ctx); return block1([], [b3]); } }" @@ -1158,7 +1253,7 @@ exports[`slots slot and t-call 2`] = ` let block1 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([], [b2]); } }" @@ -1169,18 +1264,17 @@ exports[`slots slot and t-call 3`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; - const callTemplate_5 = getTemplate(\`__template__9\`); + const callTemplate_4 = getTemplate(\`__template__9\`); let block1 = createBlock(\`
\`); - const slot3 = ctx => (node, key) => { - return callTemplate_5.call(this, ctx, node, key + \`__4\`); + const slot2 = (ctx, node, key) => { + return callTemplate_4.call(this, ctx, node, key + \`__3\`); } return function template(ctx, node, key = \\"\\") { - const ctx2 = capture(ctx); - let b3 = assign(component(\`Dialog\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot3(ctx2)}}); + const ctx1 = capture(ctx); + let b3 = component(\`Dialog\`, {slots: {'default': {__render: slot2, __ctx: ctx1}}}, key + \`__5\`, node, ctx); return block1([], [b3]); } }" @@ -1195,7 +1289,7 @@ exports[`slots slot and t-esc 1`] = ` let block1 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([], [b2]); } }" @@ -1206,16 +1300,15 @@ exports[`slots slot and t-esc 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { return text('toph'); } return function template(ctx, node, key = \\"\\") { - let b3 = assign(component(\`Dialog\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`Dialog\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); return block1([], [b3]); } }" @@ -1245,7 +1338,7 @@ exports[`slots slot are properly rendered if inner props are changed 2`] = ` let block1 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([], [b2]); } }" @@ -1256,18 +1349,17 @@ exports[`slots slot are properly rendered if inner props are changed 3`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); - const slot2 = ctx => (node, key) => { - return component(\`SomeComponent\`, {val: ctx['state'].val}, key + \`__3\`, node, ctx); + const slot1 = (ctx, node, key) => { + return component(\`SomeComponent\`, {val: ctx['state'].val}, key + \`__2\`, node, ctx); } return function template(ctx, node, key = \\"\\") { let d1 = [ctx['inc'], ctx]; let d2 = ctx['state'].val; - let b3 = assign(component(\`GenericComponent\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`GenericComponent\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__3\`, node, ctx); return block1([d1, d2], [b3]); } }" @@ -1282,7 +1374,7 @@ exports[`slots slot content is bound to caller 1`] = ` let block1 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([], [b2]); } }" @@ -1293,17 +1385,16 @@ exports[`slots slot content is bound to caller 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`\`); - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { let d1 = [ctx['inc'], ctx]; return block1([d1]); } return function template(ctx, node, key = \\"\\") { - return assign(component(\`Child\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + return component(\`Child\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); } }" `; @@ -1315,7 +1406,7 @@ exports[`slots slot preserves properly parented relationship 1`] = ` let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; return function template(ctx, node, key = \\"\\") { - return callSlot(ctx, node, key, 'default'); + return callSlot(ctx, node, key, 'default', false, {}); } }" `; @@ -1337,16 +1428,15 @@ exports[`slots slot preserves properly parented relationship 3`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); - const slot2 = ctx => (node, key) => { - return component(\`GrandChild\`, {}, key + \`__3\`, node, ctx); + const slot1 = (ctx, node, key) => { + return component(\`GrandChild\`, {}, key + \`__2\`, node, ctx); } return function template(ctx, node, key = \\"\\") { - let b3 = assign(component(\`Child\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`Child\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__3\`, node, ctx); return block1([], [b3]); } }" @@ -1359,7 +1449,7 @@ exports[`slots slot preserves properly parented relationship, even through t-cal let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; return function template(ctx, node, key = \\"\\") { - return callSlot(ctx, node, key, 'default'); + return callSlot(ctx, node, key, 'default', false, {}); } }" `; @@ -1393,18 +1483,17 @@ exports[`slots slot preserves properly parented relationship, even through t-cal ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; - const callTemplate_5 = getTemplate(\`sub\`); + const callTemplate_4 = getTemplate(\`sub\`); let block1 = createBlock(\`
\`); - const slot3 = ctx => (node, key) => { - return callTemplate_5.call(this, ctx, node, key + \`__4\`); + const slot2 = (ctx, node, key) => { + return callTemplate_4.call(this, ctx, node, key + \`__3\`); } return function template(ctx, node, key = \\"\\") { - const ctx2 = capture(ctx); - let b3 = assign(component(\`Child\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot3(ctx2)}}); + const ctx1 = capture(ctx); + let b3 = component(\`Child\`, {slots: {'default': {__render: slot2, __ctx: ctx1}}}, key + \`__5\`, node, ctx); return block1([], [b3]); } }" @@ -1419,7 +1508,7 @@ exports[`slots slots and wrapper components 1`] = ` let block1 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([], [b2]); } }" @@ -1430,14 +1519,13 @@ exports[`slots slots and wrapper components 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { return text(\`hey\`); } return function template(ctx, node, key = \\"\\") { - return assign(component(\`Link\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + return component(\`Link\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); } }" `; @@ -1451,7 +1539,7 @@ exports[`slots slots are rendered with proper context 1`] = ` let block1 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'footer'); + let b2 = callSlot(ctx, node, key, 'footer', false, {}); return block1([], [b2]); } }" @@ -1462,20 +1550,19 @@ exports[`slots slots are rendered with proper context 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); let block2 = createBlock(\`\`); - const slot3 = ctx => (node, key) => { + const slot2 = (ctx, node, key) => { let d2 = [ctx['doSomething'], ctx]; return block2([d2]); } return function template(ctx, node, key = \\"\\") { let d1 = ctx['state'].val; - const ctx2 = capture(ctx); - let b3 = assign(component(\`Dialog\`, {}, key + \`__1\`, node, ctx), {slots: {'footer': slot3(ctx2)}}); + const ctx1 = capture(ctx); + let b3 = component(\`Dialog\`, {slots: {'footer': {__render: slot2, __ctx: ctx1}}}, key + \`__3\`, node, ctx); return block1([d1], [b3]); } }" @@ -1491,7 +1578,7 @@ exports[`slots slots are rendered with proper context, part 2 1`] = ` return function template(ctx, node, key = \\"\\") { let d1 = ctx['props'].to; - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([d1], [b2]); } }" @@ -1502,12 +1589,11 @@ exports[`slots slots are rendered with proper context, part 2 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
\`); let block3 = createBlock(\`
  • \`); - const slot3 = ctx => (node, key) => { + const slot2 = (ctx, node, key) => { let b5 = text(\`User \`); let b6 = text(ctx['user'].name); return multi([b5, b6]); @@ -1519,8 +1605,8 @@ exports[`slots slots are rendered with proper context, part 2 2`] = ` for (let i1 = 0; i1 < l_block2; i1++) { ctx[\`user\`] = v_block2[i1]; let key1 = ctx['user'].id; - const ctx2 = capture(ctx); - let b7 = assign(component(\`Link\`, {to: '/user/'+ctx['user'].id}, key + \`__1__\${key1}\`, node, ctx), {slots: {'default': slot3(ctx2)}}); + const ctx1 = capture(ctx); + let b7 = component(\`Link\`, {to: '/user/'+ctx['user'].id,slots: {'default': {__render: slot2, __ctx: ctx1}}}, key + \`__3__\${key1}\`, node, ctx); c_block2[i1] = withKey(block3([], [b7]), key1); } let b2 = list(c_block2); @@ -1539,7 +1625,7 @@ exports[`slots slots are rendered with proper context, part 3 1`] = ` return function template(ctx, node, key = \\"\\") { let d1 = ctx['props'].to; - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([d1], [b2]); } }" @@ -1550,12 +1636,11 @@ exports[`slots slots are rendered with proper context, part 3 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); let block3 = createBlock(\`
  • \`); - const slot3 = ctx => (node, key) => { + const slot2 = (ctx, node, key) => { return text(ctx['userdescr']); } @@ -1568,8 +1653,8 @@ exports[`slots slots are rendered with proper context, part 3 2`] = ` ctx[\`user\`] = v_block2[i1]; let key1 = ctx['user'].id; setContextValue(ctx, \\"userdescr\\", 'User '+ctx['user'].name); - const ctx2 = capture(ctx); - let b5 = assign(component(\`Link\`, {to: '/user/'+ctx['user'].id}, key + \`__1__\${key1}\`, node, ctx), {slots: {'default': slot3(ctx2)}}); + const ctx1 = capture(ctx); + let b5 = component(\`Link\`, {to: '/user/'+ctx['user'].id,slots: {'default': {__render: slot2, __ctx: ctx1}}}, key + \`__3__\${key1}\`, node, ctx); c_block2[i1] = withKey(block3([], [b5]), key1); } let b2 = list(c_block2); @@ -1588,7 +1673,7 @@ exports[`slots slots are rendered with proper context, part 4 1`] = ` return function template(ctx, node, key = \\"\\") { let d1 = ctx['props'].to; - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([d1], [b2]); } }" @@ -1599,11 +1684,10 @@ exports[`slots slots are rendered with proper context, part 4 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); - const slot3 = ctx => (node, key) => { + const slot2 = (ctx, node, key) => { return text(ctx['userdescr']); } @@ -1611,8 +1695,8 @@ exports[`slots slots are rendered with proper context, part 4 2`] = ` ctx = Object.create(ctx); ctx[isBoundary] = 1 setContextValue(ctx, \\"userdescr\\", 'User '+ctx['state'].user.name); - const ctx2 = capture(ctx); - let b3 = assign(component(\`Link\`, {to: '/user/'+ctx['state'].user.id}, key + \`__1\`, node, ctx), {slots: {'default': slot3(ctx2)}}); + const ctx1 = capture(ctx); + let b3 = component(\`Link\`, {to: '/user/'+ctx['state'].user.id,slots: {'default': {__render: slot2, __ctx: ctx1}}}, key + \`__3\`, node, ctx); return block1([], [b3]); } }" @@ -1627,7 +1711,7 @@ exports[`slots slots in slots, with vars 1`] = ` let block1 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([], [b2]); } }" @@ -1638,16 +1722,15 @@ exports[`slots slots in slots, with vars 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); - const slot2 = ctx => (node, key) => { - return callSlot(ctx, node, key, 'default'); + const slot1 = (ctx, node, key) => { + return callSlot(ctx, node, key, 'default', false, {}); } return function template(ctx, node, key = \\"\\") { - let b3 = assign(component(\`B\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`B\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); return block1([], [b3]); } }" @@ -1658,12 +1741,11 @@ exports[`slots slots in slots, with vars 3`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); let block2 = createBlock(\`

    hey

    \`); - const slot3 = ctx => (node, key) => { + const slot2 = (ctx, node, key) => { let d1 = ctx['test']; return block2([d1]); } @@ -1672,8 +1754,8 @@ exports[`slots slots in slots, with vars 3`] = ` ctx = Object.create(ctx); ctx[isBoundary] = 1 setContextValue(ctx, \\"test\\", ctx['state'].name); - const ctx2 = capture(ctx); - let b3 = assign(component(\`A\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot3(ctx2)}}); + const ctx1 = capture(ctx); + let b3 = component(\`A\`, {slots: {'default': {__render: slot2, __ctx: ctx1}}}, key + \`__3\`, node, ctx); return block1([], [b3]); } }" @@ -1689,7 +1771,7 @@ exports[`slots slots in t-foreach and re-rendering 1`] = ` return function template(ctx, node, key = \\"\\") { let d1 = ctx['state'].val; - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([d1], [b2]); } }" @@ -1700,11 +1782,10 @@ exports[`slots slots in t-foreach and re-rendering 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); - const slot3 = ctx => (node, key) => { + const slot2 = (ctx, node, key) => { return text(ctx['n_index']); } @@ -1715,8 +1796,8 @@ exports[`slots slots in t-foreach and re-rendering 2`] = ` ctx[\`n\`] = v_block2[i1]; ctx[\`n_index\`] = i1; let key1 = ctx['n_index']; - const ctx2 = capture(ctx); - c_block2[i1] = withKey(assign(component(\`Child\`, {}, key + \`__1__\${key1}\`, node, ctx), {slots: {'default': slot3(ctx2)}}), key1); + const ctx1 = capture(ctx); + c_block2[i1] = withKey(component(\`Child\`, {slots: {'default': {__render: slot2, __ctx: ctx1}}}, key + \`__3__\${key1}\`, node, ctx), key1); } let b2 = list(c_block2); return block1([], [b2]); @@ -1733,7 +1814,7 @@ exports[`slots slots in t-foreach in t-foreach 1`] = ` let block1 = createBlock(\`
    \`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([], [b2]); } }" @@ -1744,14 +1825,13 @@ exports[`slots slots in t-foreach in t-foreach 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); let block4 = createBlock(\`
    \`); let block5 = createBlock(\`
    \`); let block7 = createBlock(\`
  • \`); - const slot3 = ctx => (node, key) => { + const slot2 = (ctx, node, key) => { let d2 = ctx['node1'].value; return block7([d2]); } @@ -1769,8 +1849,8 @@ exports[`slots slots in t-foreach in t-foreach 2`] = ` for (let i2 = 0; i2 < l_block6; i2++) { ctx[\`node2\`] = v_block6[i2]; let key2 = ctx['node2'].key; - const ctx2 = capture(ctx); - c_block6[i2] = withKey(assign(component(\`Child\`, {}, key + \`__1__\${key1}__\${key2}\`, node, ctx), {slots: {'default': slot3(ctx2)}}), key2); + const ctx1 = capture(ctx); + c_block6[i2] = withKey(component(\`Child\`, {slots: {'default': {__render: slot2, __ctx: ctx1}}}, key + \`__3__\${key1}__\${key2}\`, node, ctx), key2); } ctx = ctx.__proto__; let b6 = list(c_block6); @@ -1793,7 +1873,7 @@ exports[`slots slots in t-foreach with t-set and re-rendering 1`] = ` return function template(ctx, node, key = \\"\\") { let d1 = ctx['state'].val; - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([d1], [b2]); } }" @@ -1804,11 +1884,10 @@ exports[`slots slots in t-foreach with t-set and re-rendering 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); - const slot3 = ctx => (node, key) => { + const slot2 = (ctx, node, key) => { return text(ctx['dummy']); } @@ -1822,8 +1901,8 @@ exports[`slots slots in t-foreach with t-set and re-rendering 2`] = ` ctx[\`n_index\`] = i1; let key1 = ctx['n_index']; setContextValue(ctx, \\"dummy\\", ctx['n_index']); - const ctx2 = capture(ctx); - c_block2[i1] = withKey(assign(component(\`Child\`, {}, key + \`__1__\${key1}\`, node, ctx), {slots: {'default': slot3(ctx2)}}), key1); + const ctx1 = capture(ctx); + c_block2[i1] = withKey(component(\`Child\`, {slots: {'default': {__render: slot2, __ctx: ctx1}}}, key + \`__3__\${key1}\`, node, ctx), key1); } let b2 = list(c_block2); return block1([], [b2]); @@ -1840,7 +1919,7 @@ exports[`slots t-debug on a t-set-slot (defining a slot) 1`] = ` let block1 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'content'); + let b2 = callSlot(ctx, node, key, 'content', false, {}); return block1([], [b2]); } }" @@ -1851,18 +1930,17 @@ exports[`slots t-debug on a t-set-slot (defining a slot) 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); - const slot3 = ctx => (node, key) => { + const slot2 = (ctx, node, key) => { debugger; return text(\`abc\`); } return function template(ctx, node, key = \\"\\") { - const ctx2 = capture(ctx); - let b3 = assign(component(\`Dialog\`, {}, key + \`__1\`, node, ctx), {slots: {'content': slot3(ctx2)}}); + const ctx1 = capture(ctx); + let b3 = component(\`Dialog\`, {slots: {'content': {__render: slot2, __ctx: ctx1}}}, key + \`__3\`, node, ctx); return block1([], [b3]); } }" @@ -1877,7 +1955,7 @@ exports[`slots t-set t-value in a slot 1`] = ` let block1 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([], [b2]); } }" @@ -1888,11 +1966,10 @@ exports[`slots t-set t-value in a slot 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); - const slot3 = ctx => (node, key) => { + const slot2 = (ctx, node, key) => { setContextValue(ctx, \\"rainbow\\", 'dash'); return text(ctx['rainbow']); } @@ -1900,8 +1977,8 @@ exports[`slots t-set t-value in a slot 2`] = ` return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 - const ctx2 = capture(ctx); - let b3 = assign(component(\`Dialog\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot3(ctx2)}}); + const ctx1 = capture(ctx); + let b3 = component(\`Dialog\`, {slots: {'default': {__render: slot2, __ctx: ctx1}}}, key + \`__3\`, node, ctx); return block1([], [b3]); } }" @@ -1916,7 +1993,7 @@ exports[`slots t-slot in recursive templates 1`] = ` let block1 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([], [b2]); } }" @@ -1927,10 +2004,9 @@ exports[`slots t-slot in recursive templates 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; - const callTemplate_5 = getTemplate(\`_test_recursive_template\`); + const callTemplate_4 = getTemplate(\`_test_recursive_template\`); - const slot3 = ctx => (node, key) => { + const slot2 = (ctx, node, key) => { let b2 = text(ctx['name']); ctx = Object.create(ctx); const [k_block3, v_block3, l_block3, c_block3] = prepareList(ctx['items']); @@ -1949,7 +2025,7 @@ exports[`slots t-slot in recursive templates 2`] = ` ctx[isBoundary] = 1; setContextValue(ctx, \\"name\\", ctx['item'].name); setContextValue(ctx, \\"items\\", ctx['item'].children); - b6 = callTemplate_5.call(this, ctx, node, key + \`__4__\${key1}\`); + b6 = callTemplate_4.call(this, ctx, node, key + \`__3__\${key1}\`); ctx = ctx.__proto__; } c_block3[i1] = withKey(multi([b5, b6]), key1); @@ -1962,8 +2038,8 @@ exports[`slots t-slot in recursive templates 2`] = ` return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 - const ctx2 = capture(ctx); - return assign(component(\`Wrapper\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot3(ctx2)}}); + const ctx1 = capture(ctx); + return component(\`Wrapper\`, {slots: {'default': {__render: slot2, __ctx: ctx1}}}, key + \`__5\`, node, ctx); } }" `; @@ -1991,7 +2067,7 @@ exports[`slots t-slot nested within another slot 2`] = ` let block1 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([], [b2]); } }" @@ -2006,7 +2082,7 @@ exports[`slots t-slot nested within another slot 3`] = ` let block1 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([], [b2]); } }" @@ -2017,20 +2093,19 @@ exports[`slots t-slot nested within another slot 4`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`\`); - const slot2 = ctx => (node, key) => { - return assign(component(\`Portal\`, {}, key + \`__3\`, node, ctx), {slots: {'default': slot4(ctx)}}); + const slot1 = (ctx, node, key) => { + return component(\`Portal\`, {slots: {'default': {__render: slot2, __ctx: ctx}}}, key + \`__3\`, node, ctx); } - const slot4 = ctx => (node, key) => { - return callSlot(ctx, node, key, 'default'); + const slot2 = (ctx, node, key) => { + return callSlot(ctx, node, key, 'default', false, {}); } return function template(ctx, node, key = \\"\\") { - let b4 = assign(component(\`Modal\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b4 = component(\`Modal\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__4\`, node, ctx); return block1([], [b4]); } }" @@ -2041,16 +2116,15 @@ exports[`slots t-slot nested within another slot 5`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`\`); - const slot2 = ctx => (node, key) => { - return component(\`Child3\`, {}, key + \`__3\`, node, ctx); + const slot1 = (ctx, node, key) => { + return component(\`Child3\`, {}, key + \`__2\`, node, ctx); } return function template(ctx, node, key = \\"\\") { - let b3 = assign(component(\`Dialog\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`Dialog\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__3\`, node, ctx); return block1([], [b3]); } }" @@ -2063,7 +2137,7 @@ exports[`slots t-slot scope context 1`] = ` let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; return function template(ctx, node, key = \\"\\") { - return callSlot(ctx, node, key, 'default'); + return callSlot(ctx, node, key, 'default', false, {}); } }" `; @@ -2073,18 +2147,17 @@ exports[`slots t-slot scope context 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { let d1 = [ctx['onClick'], ctx]; - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([d1], [b2]); } return function template(ctx, node, key = \\"\\") { - return assign(component(\`Wrapper\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + return component(\`Wrapper\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); } }" `; @@ -2094,16 +2167,15 @@ exports[`slots t-slot scope context 3`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`\`); - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { return block1(); } return function template(ctx, node, key = \\"\\") { - return assign(component(\`Dialog\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + return component(\`Dialog\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); } }" `; @@ -2131,7 +2203,7 @@ exports[`slots t-slot within dynamic t-call 2`] = ` let block1 = createBlock(\`
    \`); return function template(ctx, node, key = \\"\\") { - let b2 = callSlot(ctx, node, key, 'default'); + let b2 = callSlot(ctx, node, key, 'default', false, {}); return block1([], [b2]); } }" @@ -2157,18 +2229,17 @@ exports[`slots t-slot within dynamic t-call 4`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); - const slot3 = ctx => (node, key) => { - const template5 = (ctx['tcallTemplate']); - return call(template5, ctx, node, key + \`__4\`); + const slot2 = (ctx, node, key) => { + const template4 = (ctx['tcallTemplate']); + return call(template4, ctx, node, key + \`__3\`); } return function template(ctx, node, key = \\"\\") { - const ctx2 = capture(ctx); - let b3 = assign(component(\`Slotted\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot3(ctx2)}}); + const ctx1 = capture(ctx); + let b3 = component(\`Slotted\`, {slots: {'default': {__render: slot2, __ctx: ctx1}}}, key + \`__5\`, node, ctx); return block1([], [b3]); } }" @@ -2196,7 +2267,7 @@ exports[`slots template can just return a slot 2`] = ` let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; return function template(ctx, node, key = \\"\\") { - return callSlot(ctx, node, key, 'default'); + return callSlot(ctx, node, key, 'default', false, {}); } }" `; @@ -2206,16 +2277,15 @@ exports[`slots template can just return a slot 3`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); - const slot2 = ctx => (node, key) => { - return component(\`Child\`, {value: ctx['state'].value}, key + \`__3\`, node, ctx); + const slot1 = (ctx, node, key) => { + return component(\`Child\`, {value: ctx['state'].value}, key + \`__2\`, node, ctx); } return function template(ctx, node, key = \\"\\") { - let b3 = assign(component(\`SlotComponent\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`SlotComponent\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__3\`, node, ctx); return block1([], [b3]); } }" diff --git a/tests/components/__snapshots__/t_foreach.test.ts.snap b/tests/components/__snapshots__/t_foreach.test.ts.snap index 3791e5f1..3e8f63a7 100644 --- a/tests/components/__snapshots__/t_foreach.test.ts.snap +++ b/tests/components/__snapshots__/t_foreach.test.ts.snap @@ -54,9 +54,9 @@ exports[`list of components crash on duplicate key in dev mode 1`] = ` let key1 = 'child'; if (keys1.has(key1)) { throw new Error(\`Got duplicate key in t-foreach: \${key1}\`)} keys1.add(key1); - const props2 = {} - helpers.validateProps(\`Child\`, props2, ctx) - c_block1[i1] = withKey(component(\`Child\`, props2, key + \`__1__\${key1}\`, node, ctx), key1); + const props1 = {} + helpers.validateProps(\`Child\`, props1, ctx) + c_block1[i1] = withKey(component(\`Child\`, props1, key + \`__2__\${key1}\`, node, ctx), key1); } return list(c_block1); } diff --git a/tests/components/__snapshots__/t_set.test.ts.snap b/tests/components/__snapshots__/t_set.test.ts.snap index 1c5d699a..7f88be91 100644 --- a/tests/components/__snapshots__/t_set.test.ts.snap +++ b/tests/components/__snapshots__/t_set.test.ts.snap @@ -24,11 +24,10 @@ exports[`t-set slot setted value (with t-set) not accessible with t-esc 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`

    \`); - const slot3 = ctx => (node, key) => { + const slot2 = (ctx, node, key) => { setContextValue(ctx, \\"iter\\", 'inCall'); } @@ -37,8 +36,8 @@ exports[`t-set slot setted value (with t-set) not accessible with t-esc 2`] = ` ctx[isBoundary] = 1 setContextValue(ctx, \\"iter\\", 'source'); let d1 = ctx['iter']; - const ctx2 = capture(ctx); - let b2 = assign(component(\`Childcomp\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot3(ctx2)}}); + const ctx1 = capture(ctx); + let b2 = component(\`Childcomp\`, {slots: {'default': {__render: slot2, __ctx: ctx1}}}, key + \`__3\`, node, ctx); let d2 = ctx['iter']; return block1([d1, d2], [b2]); } diff --git a/tests/components/slots.test.ts b/tests/components/slots.test.ts index 4db78079..94eb890d 100644 --- a/tests/components/slots.test.ts +++ b/tests/components/slots.test.ts @@ -37,6 +37,59 @@ describe("slots", () => { expect(fixture.innerHTML).toBe("some text"); }); + test("simple default slot with params", async () => { + let child: any; + class Child extends Component { + static template = xml``; + state = useState({ bool: true }); + setup() { + child = this; + } + } + + class Parent extends Component { + static template = xml` + + + some text + other text + + `; + static components = { Child }; + } + + await mount(Parent, fixture); + expect(fixture.innerHTML).toBe("some text"); + + child.state.bool = false; + await nextTick(); + expect(fixture.innerHTML).toBe("other text"); + }); + + test("simple default slot with params", async () => { + class Child extends Component { + static template = xml``; + state = useState({ bool: true }); + } + + class Parent extends Component { + static template = xml` + + some text + other text + `; + static components = { Child }; + } + + let error = null; + try { + await mount(Parent, fixture); + } catch (e) { + error = e; + } + expect(error).not.toBeNull(); + }); + test("fun: two calls to the same slot", async () => { class Child extends Component { static template = xml``; @@ -97,6 +150,35 @@ describe("slots", () => { ); }); + test("can define and call slots with params", async () => { + class Dialog extends Component { + static template = xml` +
    + +
    + +
    +
    `; + } + + class Parent extends Component { + static components = { Dialog }; + static template = xml` +
    + + header + footer + +
    `; + var = 3; + } + await mount(Parent, fixture); + + expect(fixture.innerHTML).toBe( + "
    3
    header
    5
    footer
    " + ); + }); + test("no named slot content => just no children", async () => { class Dialog extends Component { static template = xml``; diff --git a/tests/misc/__snapshots__/memo.test.ts.snap b/tests/misc/__snapshots__/memo.test.ts.snap index 1422ec5d..12b1eba7 100644 --- a/tests/misc/__snapshots__/memo.test.ts.snap +++ b/tests/misc/__snapshots__/memo.test.ts.snap @@ -17,9 +17,8 @@ exports[`Memo if no prop change, prevent renderings from above 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { let b6 = text(ctx['state'].a); let b7 = text(ctx['state'].b); let b8 = text(ctx['state'].c); @@ -30,7 +29,7 @@ exports[`Memo if no prop change, prevent renderings from above 2`] = ` let b2 = text(ctx['state'].a); let b3 = text(ctx['state'].b); let b4 = text(ctx['state'].c); - let b9 = assign(component(\`Memo\`, {a: ctx['state'].a,b: ctx['state'].b}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b9 = component(\`Memo\`, {a: ctx['state'].a,b: ctx['state'].b,slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); return multi([b2, b3, b4, b9]); } }" @@ -53,15 +52,14 @@ exports[`Memo if no props, prevent renderings from above 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; - const slot3 = ctx => (node, key) => { - return component(\`Child\`, {value: ctx['state'].value}, key + \`__4\`, node, ctx); + const slot2 = (ctx, node, key) => { + return component(\`Child\`, {value: ctx['state'].value}, key + \`__3\`, node, ctx); } return function template(ctx, node, key = \\"\\") { let b2 = component(\`Child\`, {value: ctx['state'].value}, key + \`__1\`, node, ctx); - let b4 = assign(component(\`Memo\`, {}, key + \`__2\`, node, ctx), {slots: {'default': slot3(ctx)}}); + let b4 = component(\`Memo\`, {slots: {'default': {__render: slot2, __ctx: ctx}}}, key + \`__4\`, node, ctx); return multi([b2, b4]); } }" @@ -72,15 +70,14 @@ exports[`Memo if no props, prevent renderings from above (work with simple html) ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { return text(ctx['state'].value); } return function template(ctx, node, key = \\"\\") { let b2 = text(ctx['state'].value); - let b4 = assign(component(\`Memo\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b4 = component(\`Memo\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); return multi([b2, b4]); } }" diff --git a/tests/misc/__snapshots__/portal.test.ts.snap b/tests/misc/__snapshots__/portal.test.ts.snap index 14a8c795..6c6a468c 100644 --- a/tests/misc/__snapshots__/portal.test.ts.snap +++ b/tests/misc/__snapshots__/portal.test.ts.snap @@ -20,14 +20,13 @@ exports[`Portal Portal composed with t-slot 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; - const slot2 = ctx => (node, key) => { - return callSlot(ctx, node, key, 'default'); + const slot1 = (ctx, node, key) => { + return callSlot(ctx, node, key, 'default', false, {}); } return function template(ctx, node, key = \\"\\") { - return assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + return component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); } }" `; @@ -37,16 +36,15 @@ exports[`Portal Portal composed with t-slot 3`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); - const slot2 = ctx => (node, key) => { - return component(\`Child2\`, {customHandler: ctx['_handled']}, key + \`__3\`, node, ctx); + const slot1 = (ctx, node, key) => { + return component(\`Child2\`, {customHandler: ctx['_handled']}, key + \`__2\`, node, ctx); } return function template(ctx, node, key = \\"\\") { - let b3 = assign(component(\`Child\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`Child\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__3\`, node, ctx); return block1([], [b3]); } }" @@ -57,17 +55,16 @@ exports[`Portal basic use of portal 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    1
    \`); let block2 = createBlock(\`

    2

    \`); - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { return block2(); } return function template(ctx, node, key = \\"\\") { - let b3 = assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); return block1([], [b3]); } }" @@ -93,19 +90,18 @@ exports[`Portal conditional use of Portal (with sub Component) 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block2 = createBlock(\`1\`); - const slot2 = ctx => (node, key) => { - return component(\`Child\`, {val: ctx['state'].val}, key + \`__3\`, node, ctx); + const slot1 = (ctx, node, key) => { + return component(\`Child\`, {val: ctx['state'].val}, key + \`__2\`, node, ctx); } return function template(ctx, node, key = \\"\\") { let b2,b4; b2 = block2(); if (ctx['state'].hasPortal) { - b4 = assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + b4 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__3\`, node, ctx); } return multi([b2, b4]); } @@ -117,12 +113,11 @@ exports[`Portal conditional use of Portal 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block2 = createBlock(\`1\`); let block3 = createBlock(\`

    2

    \`); - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { return block3(); } @@ -130,7 +125,7 @@ exports[`Portal conditional use of Portal 1`] = ` let b2,b4; b2 = block2(); if (ctx['state'].hasPortal) { - b4 = assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + b4 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); } return multi([b2, b4]); } @@ -157,18 +152,17 @@ exports[`Portal lifecycle hooks of portal sub component are properly called 2`] ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); - const slot2 = ctx => (node, key) => { - return component(\`Child\`, {val: ctx['state'].val}, key + \`__3\`, node, ctx); + const slot1 = (ctx, node, key) => { + return component(\`Child\`, {val: ctx['state'].val}, key + \`__2\`, node, ctx); } return function template(ctx, node, key = \\"\\") { let b3; if (ctx['state'].hasChild) { - b3 = assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + b3 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__3\`, node, ctx); } return block1([], [b3]); } @@ -180,12 +174,11 @@ exports[`Portal portal could have dynamically no content 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); let block3 = createBlock(\`\`); - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { let b3; if (ctx['state'].val) { let d1 = ctx['state'].val; @@ -195,7 +188,7 @@ exports[`Portal portal could have dynamically no content 1`] = ` } return function template(ctx, node, key = \\"\\") { - let b4 = assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b4 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); return block1([], [b4]); } }" @@ -221,16 +214,15 @@ exports[`Portal portal destroys on crash 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); - const slot2 = ctx => (node, key) => { - return component(\`Child\`, {error: ctx['state'].error}, key + \`__3\`, node, ctx); + const slot1 = (ctx, node, key) => { + return component(\`Child\`, {error: ctx['state'].error}, key + \`__2\`, node, ctx); } return function template(ctx, node, key = \\"\\") { - let b3 = assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__3\`, node, ctx); return block1([], [b3]); } }" @@ -256,16 +248,15 @@ exports[`Portal portal with child and props 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); - const slot2 = ctx => (node, key) => { - return component(\`Child\`, {val: ctx['state'].val}, key + \`__3\`, node, ctx); + const slot1 = (ctx, node, key) => { + return component(\`Child\`, {val: ctx['state'].val}, key + \`__2\`, node, ctx); } return function template(ctx, node, key = \\"\\") { - let b3 = assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__3\`, node, ctx); return block1([], [b3]); } }" @@ -276,13 +267,12 @@ exports[`Portal portal with dynamic body 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); let block3 = createBlock(\`\`); let block4 = createBlock(\`
    \`); - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { let b3,b4; if (ctx['state'].val) { let d1 = ctx['state'].val; @@ -294,7 +284,7 @@ exports[`Portal portal with dynamic body 1`] = ` } return function template(ctx, node, key = \\"\\") { - let b5 = assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b5 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); return block1([], [b5]); } }" @@ -305,20 +295,19 @@ exports[`Portal portal with many children 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); let block3 = createBlock(\`
    1
    \`); let block4 = createBlock(\`

    2

    \`); - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { let b3 = block3(); let b4 = block4(); return multi([b3, b4]); } return function template(ctx, node, key = \\"\\") { - let b5 = assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b5 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); return block1([], [b5]); } }" @@ -329,11 +318,10 @@ exports[`Portal portal with no content 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { let b3; if (false) { b3 = text('ABC'); @@ -342,7 +330,7 @@ exports[`Portal portal with no content 1`] = ` } return function template(ctx, node, key = \\"\\") { - let b4 = assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b4 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); return block1([], [b4]); } }" @@ -353,16 +341,15 @@ exports[`Portal portal with only text as content 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { return text('only text'); } return function template(ctx, node, key = \\"\\") { - let b3 = assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); return block1([], [b3]); } }" @@ -373,17 +360,16 @@ exports[`Portal portal with target not in dom 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); let block2 = createBlock(\`
    2
    \`); - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { return block2(); } return function template(ctx, node, key = \\"\\") { - let b3 = assign(component(\`Portal\`, {target: '#does-not-exist'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`Portal\`, {target: '#does-not-exist',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); return block1([], [b3]); } }" @@ -408,16 +394,15 @@ exports[`Portal portal's parent's env is not polluted 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); - const slot2 = ctx => (node, key) => { - return component(\`Child\`, {}, key + \`__3\`, node, ctx); + const slot1 = (ctx, node, key) => { + return component(\`Child\`, {}, key + \`__2\`, node, ctx); } return function template(ctx, node, key = \\"\\") { - let b3 = assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__3\`, node, ctx); return block1([], [b3]); } }" @@ -428,17 +413,16 @@ exports[`Portal with target in template (after portal) 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    1
    \`); let block2 = createBlock(\`

    2

    \`); - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { return block2(); } return function template(ctx, node, key = \\"\\") { - let b3 = assign(component(\`Portal\`, {target: '#local-target'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`Portal\`, {target: '#local-target',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); return block1([], [b3]); } }" @@ -449,17 +433,16 @@ exports[`Portal with target in template (before portal) 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    1
    \`); let block2 = createBlock(\`

    2

    \`); - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { return block2(); } return function template(ctx, node, key = \\"\\") { - let b3 = assign(component(\`Portal\`, {target: '#local-target'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`Portal\`, {target: '#local-target',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); return block1([], [b3]); } }" @@ -470,17 +453,16 @@ exports[`Portal: Props validation target is mandatory 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); let block2 = createBlock(\`
    2
    \`); - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { return block2(); } return function template(ctx, node, key = \\"\\") { - let b3 = assign(component(\`Portal\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`Portal\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); return block1([], [b3]); } }" @@ -491,17 +473,16 @@ exports[`Portal: Props validation target is not list 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); let block2 = createBlock(\`
    2
    \`); - const slot2 = ctx => (node, key) => { + const slot1 = (ctx, node, key) => { return block2(); } return function template(ctx, node, key = \\"\\") { - let b3 = assign(component(\`Portal\`, {target: ['body']}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`Portal\`, {target: ['body'],slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx); return block1([], [b3]); } }" @@ -527,16 +508,15 @@ exports[`Portal: UI/UX focus is kept across re-renders 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, component } = bdom; let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers; - let assign = Object.assign; let block1 = createBlock(\`
    \`); - const slot2 = ctx => (node, key) => { - return component(\`Child\`, {val: ctx['state'].val}, key + \`__3\`, node, ctx); + const slot1 = (ctx, node, key) => { + return component(\`Child\`, {val: ctx['state'].val}, key + \`__2\`, node, ctx); } return function template(ctx, node, key = \\"\\") { - let b3 = assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + let b3 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__3\`, node, ctx); return block1([], [b3]); } }"