[REF] parser: make AST definition more consistent

This commit is contained in:
Géry Debongnie
2022-03-07 14:31:17 +01:00
committed by Samuel Degueldre
parent 56086242bb
commit b3062d29f1
10 changed files with 356 additions and 293 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ function callSlot(
const { __render, __ctx, __scope } = slots[name] || {};
const slotScope = Object.create(__ctx || {});
if (__scope) {
slotScope[__scope] = extra || {};
slotScope[__scope] = extra;
}
const slotBDom = __render ? __render.call(__ctx.__owl__.component, slotScope, parent, key) : null;
if (defaultContent) {
+12 -17
View File
@@ -20,6 +20,8 @@ import {
ASTTranslation,
ASTType,
ASTTPortal,
EventHandlers,
Attrs,
} from "./parser";
type BlockType = "block" | "text" | "multi" | "list" | "html" | "comment";
@@ -157,11 +159,11 @@ class CodeTarget {
// maps ref name to [id, expr]
refInfo: { [name: string]: [string, string] } = {};
shouldProtectScope: boolean = false;
on?: { [key: string]: string };
on: EventHandlers | null;
constructor(name: string, on?: { [key: string]: string }) {
constructor(name: string, on?: EventHandlers | null) {
this.name = name;
this.on = on;
this.on = on || null;
}
addLine(line: string, idx?: number) {
@@ -305,12 +307,7 @@ export class CodeGenerator {
return code;
}
compileInNewTarget(
prefix: string,
ast: AST,
ctx: Context,
on?: { [key: string]: string }
): string {
compileInNewTarget(prefix: string, ast: AST, ctx: Context, on?: EventHandlers | null): string {
const name = this.generateId(prefix);
const initialTarget = this.target;
const target = new CodeTarget(name, on);
@@ -562,7 +559,7 @@ export class CodeGenerator {
}
}
// attributes
const attrs: { [key: string]: string } = {};
const attrs: Attrs = {};
const nameSpace = ast.ns || ctx.nameSpace;
if (nameSpace && isNewBlock) {
// specific namespace uri
@@ -1098,19 +1095,17 @@ export class CodeGenerator {
compileComponent(ast: ASTComponent, ctx: Context) {
let { block } = ctx;
// props
const hasSlotsProp = "slots" in ast.props;
const hasSlotsProp = "slots" in (ast.props || {});
const props: string[] = [];
const propExpr = this.formatPropObject(ast.props);
const propExpr = this.formatPropObject(ast.props || {});
if (propExpr) {
props.push(propExpr);
}
// slots
const hasSlot = !!Object.keys(ast.slots).length;
let slotDef: string = "";
if (hasSlot) {
if (ast.slots) {
let ctxStr = "ctx";
if (this.target.loopLevel || !this.hasSafeContext) {
ctxStr = this.generateId("ctx");
@@ -1120,7 +1115,7 @@ export class CodeGenerator {
let slotStr: string[] = [];
for (let slotName in ast.slots) {
const slotAst = ast.slots[slotName];
const name = this.compileInNewTarget("slot", slotAst.content, ctx, slotAst.on || undefined);
const name = this.compileInNewTarget("slot", slotAst.content, ctx, slotAst.on);
const params = [`__render: ${name}, __ctx: ${ctxStr}`];
const scope = ast.slots[slotName].scope;
if (scope) {
@@ -1199,7 +1194,7 @@ export class CodeGenerator {
this.insertBlock(blockExpr, block, ctx);
}
wrapWithEventCatcher(expr: string, on: { [key: string]: string }): string {
wrapWithEventCatcher(expr: string, on: EventHandlers): string {
this.helpers.add("createCatcher");
let name = this.generateId("catcher");
let spec: any = {};
+37 -35
View File
@@ -2,6 +2,9 @@
// AST Type definition
// -----------------------------------------------------------------------------
export type EventHandlers = { [eventName: string]: string };
export type Attrs = { [attrs: string]: string };
export const enum ASTType {
Text,
Comment,
@@ -34,25 +37,25 @@ export interface ASTComment {
}
interface TModelInfo {
hasDynamicChildren?: boolean;
baseExpr: string;
expr: string;
targetAttr: string;
specialInitTargetAttr: string | null;
eventType: "change" | "click" | "input";
shouldTrim: boolean;
shouldNumberize: boolean;
hasDynamicChildren: boolean;
specialInitTargetAttr: string | null;
}
export interface ASTDomNode {
type: ASTType.DomNode;
tag: string;
dynamicTag: string | null;
attrs: { [key: string]: string };
content: AST[];
attrs: Attrs | null;
ref: string | null;
on: { [key: string]: string };
model?: TModelInfo | null;
on: EventHandlers | null;
model: TModelInfo | null;
dynamicTag: string | null;
ns: string | null;
}
@@ -93,13 +96,13 @@ export interface ASTTForEach {
type: ASTType.TForEach;
collection: string;
elem: string;
key: string | null;
body: AST;
memo: string;
hasNoFirst: boolean;
hasNoLast: boolean;
hasNoIndex: boolean;
hasNoValue: boolean;
key: string | null;
}
export interface ASTTKey {
@@ -116,9 +119,9 @@ export interface ASTTCall {
interface SlotDefinition {
content: AST;
attrs?: { [key: string]: string };
scope?: string;
on?: null | { [key: string]: string };
scope: string | null;
on: EventHandlers | null;
attrs: Attrs | null;
}
export interface ASTComponent {
@@ -126,16 +129,16 @@ export interface ASTComponent {
name: string;
isDynamic: boolean;
dynamicProps: string | null;
on: null | { [key: string]: string };
props: { [name: string]: string };
slots: { [name: string]: SlotDefinition };
on: EventHandlers | null;
props: { [name: string]: string } | null;
slots: { [name: string]: SlotDefinition } | null;
}
export interface ASTSlot {
type: ASTType.TSlot;
name: string;
attrs: { [key: string]: string };
on: null | { [key: string]: string };
attrs: Attrs | null;
on: EventHandlers | null;
defaultContent: AST | null;
}
@@ -328,8 +331,8 @@ function parseDOMNode(node: Element, ctx: ParsingContext): AST | null {
node.removeAttribute("t-ref");
const nodeAttrsNames = node.getAttributeNames();
const attrs: ASTDomNode["attrs"] = {};
const on: ASTDomNode["on"] = {};
let attrs: ASTDomNode["attrs"] = null;
let on: EventHandlers | null = null;
let model: TModelInfo | null = null;
for (let attr of nodeAttrsNames) {
@@ -338,6 +341,7 @@ function parseDOMNode(node: Element, ctx: ParsingContext): AST | null {
if (attr === "t-on") {
throw new Error("Missing event name with t-on directive");
}
on = on || {};
on[attr.slice(5)] = value;
} else if (attr.startsWith("t-model")) {
if (!["input", "select", "textarea"].includes(tagName)) {
@@ -375,6 +379,7 @@ function parseDOMNode(node: Element, ctx: ParsingContext): AST | null {
targetAttr: isCheckboxInput ? "checked" : "value",
specialInitTargetAttr: isRadioInput ? "checked" : null,
eventType,
hasDynamicChildren: false,
shouldTrim: hasTrimMod && (isOtherInput || isTextarea),
shouldNumberize: hasNumberMod && (isOtherInput || isTextarea),
};
@@ -393,6 +398,7 @@ function parseDOMNode(node: Element, ctx: ParsingContext): AST | null {
if (tModel && ["t-att-value", "t-attf-value"].includes(attr)) {
tModel.hasDynamicChildren = true;
}
attrs = attrs || {};
attrs[attr] = value;
}
}
@@ -563,7 +569,7 @@ function parseTCall(node: Element, ctx: ParsingContext): AST | null {
if (ast && ast.type === ASTType.TComponent) {
return {
...ast,
slots: { default: { content: tcall } },
slots: { default: { content: tcall, scope: null, on: null, attrs: null } },
};
}
}
@@ -694,7 +700,7 @@ function parseComponent(node: Element, ctx: ParsingContext): AST | null {
node.removeAttribute("t-slot-scope");
let on: ASTComponent["on"] = null;
const props: ASTComponent["props"] = {};
let props: ASTComponent["props"] = null;
for (let name of node.getAttributeNames()) {
const value = node.getAttribute(name)!;
if (name.startsWith("t-")) {
@@ -706,11 +712,12 @@ function parseComponent(node: Element, ctx: ParsingContext): AST | null {
throw new Error(message || `unsupported directive on Component: ${name}`);
}
} else {
props = props || {};
props[name] = value;
}
}
const slots: ASTComponent["slots"] = {};
let slots: ASTComponent["slots"] | null = null;
if (node.hasChildNodes()) {
const clone = <Element>node.cloneNode(true);
@@ -743,38 +750,32 @@ function parseComponent(node: Element, ctx: ParsingContext): AST | null {
slotNode.remove();
const slotAst = parseNode(slotNode, ctx);
if (slotAst) {
const slotInfo: any = { content: slotAst };
let on: SlotDefinition["on"] = null;
const attrs: { [key: string]: string } = {};
let attrs: Attrs | null = null;
let scope: string | null = null;
for (let attributeName of slotNode.getAttributeNames()) {
const value = slotNode.getAttribute(attributeName)!;
if (attributeName === "t-slot-scope") {
slotInfo.scope = value;
scope = value;
continue;
} else if (attributeName.startsWith("t-on-")) {
on = on || {};
on[attributeName.slice(5)] = value;
} else {
attrs = attrs || {};
attrs[attributeName] = value;
}
}
if (Object.keys(attrs).length) {
slotInfo.attrs = attrs;
}
if (on) {
slotInfo.on = on;
}
slots[name] = slotInfo;
slots = slots || {};
slots[name] = { content: slotAst, on, attrs, scope };
}
}
// default slot
const defaultContent = parseChildNodes(clone, ctx);
if (defaultContent) {
slots.default = { content: defaultContent };
if (defaultSlotScope) {
slots.default.scope = defaultSlotScope;
}
slots = slots || {};
slots.default = { content: defaultContent, on, attrs: null, scope: defaultSlotScope };
}
}
return { type: ASTType.TComponent, name, isDynamic, dynamicProps, props, slots, on };
@@ -790,7 +791,7 @@ function parseTSlot(node: Element, ctx: ParsingContext): AST | null {
}
const name = node.getAttribute("t-slot")!;
node.removeAttribute("t-slot");
const attrs: { [key: string]: string } = {};
let attrs: Attrs | null = null;
let on: ASTComponent["on"] = null;
for (let attributeName of node.getAttributeNames()) {
const value = node.getAttribute(attributeName)!;
@@ -798,6 +799,7 @@ function parseTSlot(node: Element, ctx: ParsingContext): AST | null {
on = on || {};
on[attributeName.slice(5)] = value;
} else {
attrs = attrs || {};
attrs[attributeName] = value;
}
}
+212 -146
View File
@@ -42,8 +42,8 @@ describe("qweb parser", () => {
tag: "div",
dynamicTag: null,
content: [],
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -69,8 +69,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "div",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
content: [],
@@ -83,8 +83,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "div",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
content: [{ type: ASTType.Text, value: "some text" }],
@@ -97,8 +97,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "div",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -108,8 +108,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "span",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -127,8 +127,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "div",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -138,8 +138,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "span",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -155,8 +155,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "div",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -180,8 +180,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "div",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -200,8 +200,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "div",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -222,8 +222,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "div",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -245,8 +245,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "span",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -262,7 +262,7 @@ describe("qweb parser", () => {
tag: "div",
dynamicTag: null,
attrs: { class: "abc" },
on: {},
on: null,
ref: null,
model: null,
ns: null,
@@ -294,7 +294,7 @@ describe("qweb parser", () => {
dynamicTag: null,
model: null,
ns: null,
on: {},
on: null,
ref: null,
tag: "circle",
type: 2,
@@ -303,7 +303,7 @@ describe("qweb parser", () => {
dynamicTag: null,
model: null,
ns: "http://www.w3.org/2000/svg",
on: {},
on: null,
ref: null,
tag: "svg",
type: 2,
@@ -311,7 +311,7 @@ describe("qweb parser", () => {
expect(
parse(`<g><circle cx="50" cy="50" r="4" stroke="green" stroke-width="1" fill="yellow"/></g>`)
).toEqual({
attrs: {},
attrs: null,
content: [
{
attrs: {
@@ -326,7 +326,7 @@ describe("qweb parser", () => {
dynamicTag: null,
model: null,
ns: null,
on: {},
on: null,
ref: null,
tag: "circle",
type: 2,
@@ -335,7 +335,7 @@ describe("qweb parser", () => {
dynamicTag: null,
model: null,
ns: "http://www.w3.org/2000/svg",
on: {},
on: null,
ref: null,
tag: "g",
type: 2,
@@ -347,16 +347,16 @@ describe("qweb parser", () => {
type: 2,
tag: "div",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
content: [
{
type: 2,
tag: "pre",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
content: [],
model: null,
@@ -390,8 +390,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "span",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -412,8 +412,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "div",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -454,8 +454,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "div",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -468,8 +468,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "div",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -488,8 +488,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "div",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -529,8 +529,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "div",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -606,8 +606,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "div",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -625,8 +625,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "h1",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -638,8 +638,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "h2",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -684,8 +684,8 @@ describe("qweb parser", () => {
body: [
{
type: ASTType.DomNode,
attrs: {},
on: {},
attrs: null,
on: null,
tag: "div",
dynamicTag: null,
ref: null,
@@ -704,8 +704,8 @@ describe("qweb parser", () => {
body: [
{
type: ASTType.DomNode,
attrs: {},
on: {},
attrs: null,
on: null,
tag: "div",
dynamicTag: null,
ref: null,
@@ -741,8 +741,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "div",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -810,8 +810,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "div",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -852,8 +852,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "span",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -886,8 +886,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "span",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -920,7 +920,7 @@ describe("qweb parser", () => {
"t-att-selected": "category.id==options.active_category_id",
"t-att-value": "category.id",
},
on: {},
on: null,
ref: null,
model: null,
ns: null,
@@ -939,8 +939,8 @@ describe("qweb parser", () => {
parse(`<div><t t-foreach="list" t-as="item" t-key="item_index"><t t-esc="item"/></t></div>`)
).toEqual({
type: ASTType.DomNode,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
tag: "div",
@@ -983,10 +983,10 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "span",
dynamicTag: null,
on: {},
on: null,
ref: null,
model: null,
attrs: {},
attrs: null,
ns: null,
content: [{ type: ASTType.TEsc, expr: "item", defaultValue: "" }],
},
@@ -1009,8 +1009,8 @@ describe("qweb parser", () => {
isDynamic: false,
name: "Comp",
dynamicProps: null,
props: {},
slots: {},
props: null,
slots: null,
on: null,
},
memo: "",
@@ -1086,8 +1086,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "div",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -1124,7 +1124,7 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "button",
dynamicTag: null,
attrs: {},
attrs: null,
on: { click: "add" },
ref: null,
model: null,
@@ -1142,8 +1142,8 @@ describe("qweb parser", () => {
type: 2,
tag: "select",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
content: [
{
@@ -1151,7 +1151,7 @@ describe("qweb parser", () => {
tag: "option",
dynamicTag: null,
attrs: { value: "1" },
on: {},
on: null,
ref: null,
content: [],
model: null,
@@ -1162,6 +1162,7 @@ describe("qweb parser", () => {
baseExpr: "state",
expr: "'model'",
targetAttr: "value",
hasDynamicChildren: false,
specialInitTargetAttr: null,
eventType: "change",
shouldTrim: false,
@@ -1178,8 +1179,8 @@ describe("qweb parser", () => {
type: 2,
tag: "select",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
content: [
{
@@ -1187,7 +1188,7 @@ describe("qweb parser", () => {
tag: "option",
dynamicTag: null,
attrs: { "t-att-value": "valueVar" },
on: {},
on: null,
ref: null,
content: [],
model: null,
@@ -1217,9 +1218,9 @@ describe("qweb parser", () => {
type: ASTType.TComponent,
name: "MyComponent",
dynamicProps: null,
props: {},
props: null,
on: null,
slots: {},
slots: null,
isDynamic: false,
});
});
@@ -1232,7 +1233,7 @@ describe("qweb parser", () => {
props: { a: "1", b: "'b'" },
isDynamic: false,
on: null,
slots: {},
slots: null,
});
});
@@ -1244,7 +1245,7 @@ describe("qweb parser", () => {
props: { a: "1" },
isDynamic: false,
on: null,
slots: {},
slots: null,
});
});
@@ -1253,10 +1254,10 @@ describe("qweb parser", () => {
type: ASTType.TComponent,
name: "MyComponent",
dynamicProps: null,
props: {},
props: null,
isDynamic: false,
on: { click: "someMethod" },
slots: {},
slots: null,
});
});
@@ -1289,10 +1290,17 @@ describe("qweb parser", () => {
type: ASTType.TComponent,
name: "MyComponent",
dynamicProps: null,
props: {},
props: null,
isDynamic: false,
on: null,
slots: { default: { content: { type: ASTType.Text, value: "foo" } } },
slots: {
default: {
content: { type: ASTType.Text, value: "foo" },
attrs: null,
on: null,
scope: null,
},
},
});
});
@@ -1303,11 +1311,16 @@ describe("qweb parser", () => {
type: ASTType.TComponent,
name: "MyComponent",
dynamicProps: null,
props: {},
props: null,
isDynamic: false,
on: null,
slots: {
default: { content: { type: ASTType.Text, value: "foo" }, attrs: { param: "param" } },
default: {
content: { type: ASTType.Text, value: "foo" },
attrs: { param: "param" },
on: null,
scope: null,
},
},
});
});
@@ -1318,7 +1331,7 @@ describe("qweb parser", () => {
name: "MyComponent",
isDynamic: false,
dynamicProps: null,
props: {},
props: null,
on: null,
slots: {
default: {
@@ -1329,26 +1342,29 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "span",
dynamicTag: null,
attrs: {},
attrs: null,
content: [],
ref: null,
model: null,
on: {},
on: null,
ns: null,
},
{
type: ASTType.DomNode,
tag: "div",
dynamicTag: null,
attrs: {},
attrs: null,
content: [],
ref: null,
model: null,
on: {},
on: null,
ns: null,
},
],
},
attrs: null,
on: null,
scope: null,
},
},
});
@@ -1360,9 +1376,11 @@ describe("qweb parser", () => {
name: "MyComponent",
isDynamic: false,
dynamicProps: null,
props: {},
props: null,
on: null,
slots: { name: { content: { type: ASTType.Text, value: "foo" } } },
slots: {
name: { content: { type: ASTType.Text, value: "foo" }, attrs: null, on: null, scope: null },
},
});
});
@@ -1372,9 +1390,16 @@ describe("qweb parser", () => {
name: "MyComponent",
isDynamic: false,
dynamicProps: null,
props: {},
props: null,
on: null,
slots: { name: { content: { type: ASTType.Text, value: "foo" }, attrs: { param: "param" } } },
slots: {
name: {
content: { type: ASTType.Text, value: "foo" },
attrs: { param: "param" },
on: null,
scope: null,
},
},
});
});
@@ -1386,12 +1411,14 @@ describe("qweb parser", () => {
name: "MyComponent",
isDynamic: false,
dynamicProps: null,
props: {},
props: null,
on: null,
slots: {
name: {
content: { type: ASTType.Text, value: "foo" },
on: { click: "doStuff" },
attrs: null,
scope: null,
},
},
});
@@ -1408,12 +1435,17 @@ describe("qweb parser", () => {
type: ASTType.TComponent,
name: "MyComponent",
dynamicProps: null,
props: {},
props: null,
isDynamic: false,
on: null,
slots: {
default: { content: { type: ASTType.Text, value: " " } },
name: { content: { type: ASTType.Text, value: "foo" } },
default: {
content: { type: ASTType.Text, value: " " },
attrs: null,
on: null,
scope: null,
},
name: { content: { type: ASTType.Text, value: "foo" }, attrs: null, on: null, scope: null },
},
});
});
@@ -1428,12 +1460,12 @@ describe("qweb parser", () => {
type: ASTType.TComponent,
name: "MyComponent",
dynamicProps: null,
props: {},
props: null,
isDynamic: false,
on: null,
slots: {
a: { content: { type: ASTType.Text, value: "foo" } },
b: { content: { type: ASTType.Text, value: "bar" } },
a: { content: { type: ASTType.Text, value: "foo" }, attrs: null, on: null, scope: null },
b: { content: { type: ASTType.Text, value: "bar" }, attrs: null, on: null, scope: null },
},
});
});
@@ -1443,10 +1475,10 @@ describe("qweb parser", () => {
type: ASTType.TComponent,
name: "myComponent",
dynamicProps: null,
props: {},
props: null,
isDynamic: true,
on: null,
slots: {},
slots: null,
});
});
@@ -1458,7 +1490,7 @@ describe("qweb parser", () => {
props: { a: "1", b: "'b'" },
isDynamic: true,
on: null,
slots: {},
slots: null,
});
});
@@ -1470,7 +1502,7 @@ describe("qweb parser", () => {
props: { a: "1" },
isDynamic: true,
on: null,
slots: {},
slots: null,
});
});
@@ -1491,10 +1523,17 @@ describe("qweb parser", () => {
type: ASTType.TComponent,
name: "MyComponent",
dynamicProps: null,
props: {},
props: null,
isDynamic: false,
on: null,
slots: { default: { content: { body: null, name: "subTemplate", type: ASTType.TCall } } },
slots: {
default: {
content: { body: null, name: "subTemplate", type: ASTType.TCall },
attrs: null,
scope: null,
on: null,
},
},
});
});
@@ -1510,19 +1549,29 @@ describe("qweb parser", () => {
type: ASTType.TComponent,
name: "MyComponent",
dynamicProps: null,
props: {},
props: null,
isDynamic: false,
on: null,
slots: {
default: {
attrs: null,
on: null,
scope: null,
content: {
type: ASTType.TComponent,
isDynamic: false,
name: "Child",
dynamicProps: null,
props: {},
props: null,
on: null,
slots: { brol: { content: { type: ASTType.Text, value: "coucou" } } },
slots: {
brol: {
content: { type: ASTType.Text, value: "coucou" },
attrs: null,
scope: null,
on: null,
},
},
},
},
},
@@ -1541,19 +1590,29 @@ describe("qweb parser", () => {
type: ASTType.TComponent,
name: "MyComponent",
dynamicProps: null,
props: {},
props: null,
isDynamic: false,
on: null,
slots: {
default: {
attrs: null,
on: null,
scope: null,
content: {
type: ASTType.TComponent,
isDynamic: false,
name: "Child",
dynamicProps: null,
props: {},
props: null,
on: null,
slots: { brol: { content: { type: ASTType.Text, value: "coucou" } } },
slots: {
brol: {
content: { type: ASTType.Text, value: "coucou" },
attrs: null,
on: null,
scope: null,
},
},
},
},
},
@@ -1568,7 +1627,7 @@ describe("qweb parser", () => {
expect(parse(`<t t-slot="default"/>`)).toEqual({
type: ASTType.TSlot,
name: "default",
attrs: {},
attrs: null,
on: null,
defaultContent: null,
});
@@ -1578,7 +1637,7 @@ describe("qweb parser", () => {
expect(parse(`<t t-slot="header">default content</t>`)).toEqual({
type: ASTType.TSlot,
name: "header",
attrs: {},
attrs: null,
on: null,
defaultContent: { type: ASTType.Text, value: "default content" },
});
@@ -1588,7 +1647,7 @@ describe("qweb parser", () => {
expect(parse(`<t t-slot="default" t-on-click.prevent="doSomething"/>`)).toEqual({
type: ASTType.TSlot,
name: "default",
attrs: {},
attrs: null,
on: { "click.prevent": "doSomething" },
defaultContent: null,
});
@@ -1605,8 +1664,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "div",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -1623,8 +1682,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "div",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: null,
model: null,
ns: null,
@@ -1642,8 +1701,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "div",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: "name",
model: null,
ns: null,
@@ -1656,8 +1715,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "div",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: "name",
model: null,
ns: null,
@@ -1672,8 +1731,8 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
tag: "div",
dynamicTag: null,
attrs: {},
on: {},
attrs: null,
on: null,
ref: "name",
model: null,
ns: null,
@@ -1708,14 +1767,14 @@ describe("qweb parser", () => {
).toEqual({
body: {
content: {
attrs: {},
attrs: null,
content: [
{
type: ASTType.Text,
value: "word",
},
],
on: {},
on: null,
ref: null,
model: null,
tag: "div",
@@ -1743,9 +1802,9 @@ describe("qweb parser", () => {
test("t-model", async () => {
expect(parse(`<input t-model="state.stuff" />`)).toEqual({
type: ASTType.DomNode,
attrs: {},
attrs: null,
content: [],
on: {},
on: null,
ref: null,
tag: "input",
dynamicTag: null,
@@ -1756,15 +1815,16 @@ describe("qweb parser", () => {
eventType: "input",
shouldNumberize: false,
shouldTrim: false,
hasDynamicChildren: false,
targetAttr: "value",
specialInitTargetAttr: null,
},
});
expect(parse(`<input t-model="state['stuff']" />`)).toEqual({
type: ASTType.DomNode,
attrs: {},
attrs: null,
content: [],
on: {},
on: null,
ref: null,
tag: "input",
dynamicTag: null,
@@ -1777,13 +1837,14 @@ describe("qweb parser", () => {
shouldTrim: false,
targetAttr: "value",
specialInitTargetAttr: null,
hasDynamicChildren: false,
},
});
expect(parse(`<input t-model.lazy.trim.number="state.stuff" />`)).toEqual({
type: ASTType.DomNode,
attrs: {},
attrs: null,
content: [],
on: {},
on: null,
ref: null,
tag: "input",
dynamicTag: null,
@@ -1795,15 +1856,16 @@ describe("qweb parser", () => {
shouldNumberize: true,
shouldTrim: true,
targetAttr: "value",
hasDynamicChildren: false,
specialInitTargetAttr: null,
},
});
});
expect(parse(`<textarea t-model="state.stuff" />`)).toEqual({
type: ASTType.DomNode,
attrs: {},
attrs: null,
content: [],
on: {},
on: null,
ref: null,
tag: "textarea",
dynamicTag: null,
@@ -1815,6 +1877,7 @@ describe("qweb parser", () => {
shouldNumberize: false,
shouldTrim: false,
targetAttr: "value",
hasDynamicChildren: false,
specialInitTargetAttr: null,
},
});
@@ -1822,7 +1885,7 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
attrs: { type: "checkbox" },
content: [],
on: {},
on: null,
ref: null,
tag: "input",
dynamicTag: null,
@@ -1834,6 +1897,7 @@ describe("qweb parser", () => {
shouldNumberize: false,
shouldTrim: false,
targetAttr: "checked",
hasDynamicChildren: false,
specialInitTargetAttr: null,
},
});
@@ -1841,7 +1905,7 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
attrs: { type: "radio" },
content: [],
on: {},
on: null,
ref: null,
tag: "input",
dynamicTag: null,
@@ -1853,6 +1917,7 @@ describe("qweb parser", () => {
shouldNumberize: false,
shouldTrim: false,
targetAttr: "value",
hasDynamicChildren: false,
specialInitTargetAttr: "checked",
},
});
@@ -1860,7 +1925,7 @@ describe("qweb parser", () => {
type: ASTType.DomNode,
attrs: { type: "radio" },
content: [],
on: {},
on: null,
ref: null,
tag: "input",
dynamicTag: null,
@@ -1872,6 +1937,7 @@ describe("qweb parser", () => {
shouldNumberize: false,
shouldTrim: false,
targetAttr: "value",
hasDynamicChildren: false,
specialInitTargetAttr: "checked",
},
});
@@ -1882,9 +1948,9 @@ describe("qweb parser", () => {
test("t-tag", async () => {
expect(parse(`<div t-tag="theTag" />`)).toEqual({
type: ASTType.DomNode,
attrs: {},
attrs: null,
content: [],
on: {},
on: null,
ref: null,
tag: "div",
dynamicTag: "theTag",
@@ -128,7 +128,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', false, {});
b3 = callSlot(ctx, node, key, 'default', false, null);
}
return block1([], [b2, b3]);
}
@@ -181,7 +181,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', false, {});
b3 = callSlot(ctx, node, key, 'default', false, null);
}
return block1([], [b2, b3]);
}
@@ -222,7 +222,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', false, {});
b3 = callSlot(ctx, node, key, 'default', false, null);
}
return block1([], [b2, b3]);
}
@@ -300,7 +300,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', false, {});
b3 = callSlot(ctx, node, key, 'default', false, null);
}
return block1([], [b2, b3]);
}
@@ -356,7 +356,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', false, {});
b3 = callSlot(ctx, node, key, 'default', false, null);
}
return block1([], [b2, b3]);
}
@@ -498,7 +498,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', false, {});
b3 = callSlot(ctx, node, key, 'default', false, null);
}
return block1([], [b2, b3]);
}
@@ -551,7 +551,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', false, {});
b3 = callSlot(ctx, node, key, 'default', false, null);
}
return block1([], [b2, b3]);
}
@@ -604,7 +604,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', false, {});
b3 = callSlot(ctx, node, key, 'default', false, null);
}
return block1([], [b2, b3]);
}
@@ -658,7 +658,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', false, {});
b3 = callSlot(ctx, node, key, 'default', false, null);
}
return block1([], [b2, b3]);
}
@@ -771,7 +771,7 @@ exports[`can catch errors catching error, rethrow, render parent -- a main comp
let { callSlot } = helpers;
return function template(ctx, node, key = \\"\\") {
return callSlot(ctx, node, key, 'default', false, {});
return callSlot(ctx, node, key, 'default', false, null);
}
}"
`;
@@ -846,7 +846,7 @@ exports[`can catch errors catching in child makes parent render 2`] = `
let { callSlot } = helpers;
return function template(ctx, node, key = \\"\\") {
return callSlot(ctx, node, key, 'default', false, {});
return callSlot(ctx, node, key, 'default', false, null);
}
}"
`;
@@ -922,7 +922,7 @@ exports[`can catch errors error in mounted on a component with a sibling (proper
if (ctx['state'].error) {
b2 = text(\`Error handled\`);
} else {
b3 = callSlot(ctx, node, key, 'default', false, {});
b3 = callSlot(ctx, node, key, 'default', false, null);
}
return block1([], [b2, b3]);
}
@@ -92,7 +92,7 @@ exports[`refs refs are properly bound in slots 2`] = `
let block1 = createBlock(\`<span><block-child-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'footer', false, {});
const b2 = callSlot(ctx, node, key, 'footer', false, null);
return block1([], [b2]);
}
}"
@@ -27,7 +27,7 @@ exports[`slots can define a default content 2`] = `
}
return function template(ctx, node, key = \\"\\") {
const b3 = callSlot(ctx, node, key, 'default', false, {}, defaultContent1);
const b3 = callSlot(ctx, node, key, 'default', false, null, defaultContent1);
return block1([], [b3]);
}
}"
@@ -68,8 +68,8 @@ exports[`slots can define and call slots 2`] = `
let block1 = createBlock(\`<div><div><block-child-0/></div><div><block-child-1/></div></div>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'header', false, {});
const b3 = callSlot(ctx, node, key, 'footer', false, {});
const b2 = callSlot(ctx, node, key, 'header', false, null);
const b3 = callSlot(ctx, node, key, 'footer', false, null);
return block1([], [b2, b3]);
}
}"
@@ -99,7 +99,7 @@ exports[`slots can define and call slots with bound params 2`] = `
let { callSlot } = helpers;
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'abc', false, {});
const b2 = callSlot(ctx, node, key, 'abc', false, null);
const b3 = text(ctx['props'].slots['abc'].getValue());
return multi([b2, b3]);
}
@@ -142,9 +142,9 @@ exports[`slots can define and call slots with params 2`] = `
return function template(ctx, node, key = \\"\\") {
let txt1 = ctx['props'].slots['header'].param;
const b2 = callSlot(ctx, node, key, 'header', false, {});
const b2 = callSlot(ctx, node, key, 'header', false, null);
let txt2 = ctx['props'].slots['footer'].param;
const b3 = callSlot(ctx, node, key, 'footer', false, {});
const b3 = callSlot(ctx, node, key, 'footer', false, null);
return block1([txt1, txt2], [b2, b3]);
}
}"
@@ -179,7 +179,7 @@ exports[`slots can render node with t-ref and Component in same slot 2`] = `
let { callSlot } = helpers;
return function template(ctx, node, key = \\"\\") {
return callSlot(ctx, node, key, 'default', false, {});
return callSlot(ctx, node, key, 'default', false, null);
}
}"
`;
@@ -191,7 +191,7 @@ exports[`slots can render only empty slot 1`] = `
let { callSlot } = helpers;
return function template(ctx, node, key = \\"\\") {
return callSlot(ctx, node, key, 'default', false, {});
return callSlot(ctx, node, key, 'default', false, null);
}
}"
`;
@@ -218,7 +218,7 @@ exports[`slots can use component in default-content of t-slot 2`] = `
}
return function template(ctx, node, key = \\"\\") {
return callSlot(ctx, node, key, 'default', false, {}, defaultContent1);
return callSlot(ctx, node, key, 'default', false, null, defaultContent1);
}
}"
`;
@@ -257,7 +257,7 @@ exports[`slots can use t-call in default-content of t-slot 2`] = `
}
return function template(ctx, node, key = \\"\\") {
return callSlot(ctx, node, key, 'default', false, {}, defaultContent1);
return callSlot(ctx, node, key, 'default', false, null, defaultContent1);
}
}"
`;
@@ -298,7 +298,7 @@ exports[`slots content is the default slot (variation) 2`] = `
let { callSlot } = helpers;
return function template(ctx, node, key = \\"\\") {
return callSlot(ctx, node, key, 'default', false, {});
return callSlot(ctx, node, key, 'default', false, null);
}
}"
`;
@@ -332,7 +332,7 @@ exports[`slots content is the default slot 2`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([], [b2]);
}
}"
@@ -371,7 +371,7 @@ exports[`slots default content is not rendered if named slot is provided 2`] = `
}
return function template(ctx, node, key = \\"\\") {
const b3 = callSlot(ctx, node, key, 'header', false, {}, defaultContent1);
const b3 = callSlot(ctx, node, key, 'header', false, null, defaultContent1);
return block1([], [b3]);
}
}"
@@ -409,7 +409,7 @@ exports[`slots default content is not rendered if slot is provided 2`] = `
}
return function template(ctx, node, key = \\"\\") {
const b3 = callSlot(ctx, node, key, 'default', false, {}, defaultContent1);
const b3 = callSlot(ctx, node, key, 'default', false, null, defaultContent1);
return block1([], [b3]);
}
}"
@@ -452,8 +452,8 @@ exports[`slots default slot next to named slot, with default content 2`] = `
}
return function template(ctx, node, key = \\"\\") {
const b3 = callSlot(ctx, node, key, 'default', false, {}, defaultContent1);
const b5 = callSlot(ctx, node, key, 'footer', false, {}, defaultContent2);
const b3 = callSlot(ctx, node, key, 'default', false, null, defaultContent1);
const b5 = callSlot(ctx, node, key, 'footer', false, null, defaultContent2);
return block1([], [b3, b5]);
}
}"
@@ -547,7 +547,7 @@ exports[`slots default slot work with text nodes (variation) 2`] = `
let { callSlot } = helpers;
return function template(ctx, node, key = \\"\\") {
return callSlot(ctx, node, key, 'default', false, {});
return callSlot(ctx, node, key, 'default', false, null);
}
}"
`;
@@ -580,7 +580,7 @@ exports[`slots default slot work with text nodes 2`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([], [b2]);
}
}"
@@ -626,7 +626,7 @@ exports[`slots dynamic t-slot call 2`] = `
return function template(ctx, node, key = \\"\\") {
let hdlr1 = [ctx['toggle'], ctx];
const slot1 = (ctx['current'].slot);
const b2 = toggler(slot1, callSlot(ctx, node, key, slot1), true, {});
const b2 = toggler(slot1, callSlot(ctx, node, key, slot1), true, null);
return block1([hdlr1], [b2]);
}
}"
@@ -675,7 +675,7 @@ exports[`slots dynamic t-slot call with default 2`] = `
return function template(ctx, node, key = \\"\\") {
let hdlr1 = [ctx['toggle'], ctx];
const b3 = callSlot(ctx, node, key, (ctx['current'].slot), true, {}, defaultContent1);
const b3 = callSlot(ctx, node, key, (ctx['current'].slot), true, null, defaultContent1);
return block1([hdlr1], [b3]);
}
}"
@@ -704,8 +704,8 @@ exports[`slots fun: two calls to the same slot 2`] = `
let { callSlot } = helpers;
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b3 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
const b3 = callSlot(ctx, node, key, 'default', false, null);
return multi([b2, b3]);
}
}"
@@ -734,8 +734,8 @@ exports[`slots missing slots are ignored 2`] = `
let block1 = createBlock(\`<span><block-child-0/><span>some content</span><block-child-1/></span>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b3 = callSlot(ctx, node, key, 'footer', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
const b3 = callSlot(ctx, node, key, 'footer', false, null);
return block1([], [b2, b3]);
}
}"
@@ -844,7 +844,7 @@ exports[`slots mix of slots, t-call, t-call with body, and giving own props chil
return function template(ctx, node, key = \\"\\") {
const b2 = text(\`[C]\`);
const b3 = callSlot(ctx, node, key, 'default', false, {});
const b3 = callSlot(ctx, node, key, 'default', false, null);
return multi([b2, b3]);
}
}"
@@ -882,7 +882,7 @@ exports[`slots multiple roots are allowed in a default slot 2`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([], [b2]);
}
}"
@@ -921,7 +921,7 @@ exports[`slots multiple roots are allowed in a named slot 2`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'content', false, {});
const b2 = callSlot(ctx, node, key, 'content', false, null);
return block1([], [b2]);
}
}"
@@ -957,8 +957,8 @@ exports[`slots multiple slots containing components 2`] = `
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 's1', false, {});
const b3 = callSlot(ctx, node, key, 's2', false, {});
const b2 = callSlot(ctx, node, key, 's1', false, null);
const b3 = callSlot(ctx, node, key, 's2', false, null);
return block1([], [b2, b3]);
}
}"
@@ -1020,8 +1020,8 @@ exports[`slots named slot inside slot 2`] = `
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'brol', false, {});
const b3 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'brol', false, null);
const b3 = callSlot(ctx, node, key, 'default', false, null);
return block1([], [b2, b3]);
}
}"
@@ -1069,8 +1069,8 @@ exports[`slots named slot inside slot, part 3 2`] = `
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'brol', false, {});
const b3 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'brol', false, null);
const b3 = callSlot(ctx, node, key, 'default', false, null);
return block1([], [b2, b3]);
}
}"
@@ -1103,7 +1103,7 @@ exports[`slots named slots can define a default content 2`] = `
}
return function template(ctx, node, key = \\"\\") {
const b3 = callSlot(ctx, node, key, 'header', false, {}, defaultContent1);
const b3 = callSlot(ctx, node, key, 'header', false, null, defaultContent1);
return block1([], [b3]);
}
}"
@@ -1159,9 +1159,9 @@ exports[`slots named slots inside slot, again 2`] = `
}
return function template(ctx, node, key = \\"\\") {
const b3 = callSlot(ctx, node, key, 'brol1', false, {}, defaultContent1);
const b5 = callSlot(ctx, node, key, 'brol2', false, {}, defaultContent2);
const b6 = callSlot(ctx, node, key, 'default', false, {});
const b3 = callSlot(ctx, node, key, 'brol1', false, null, defaultContent1);
const b5 = callSlot(ctx, node, key, 'brol2', false, null, defaultContent2);
const b6 = callSlot(ctx, node, key, 'default', false, null);
return block1([], [b3, b5, b6]);
}
}"
@@ -1199,7 +1199,7 @@ exports[`slots nested slots in same template 2`] = `
let block1 = createBlock(\`<span id=\\"c1\\"><div><block-child-0/></div></span>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([], [b2]);
}
}"
@@ -1214,7 +1214,7 @@ exports[`slots nested slots in same template 3`] = `
let block1 = createBlock(\`<span id=\\"c2\\"><block-child-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([], [b2]);
}
}"
@@ -1256,7 +1256,7 @@ exports[`slots nested slots: evaluation context and parented relationship 2`] =
let { callSlot, markRaw } = helpers;
function slot1(ctx, node, key = \\"\\") {
return callSlot(ctx, node, key, 'default', false, {});
return callSlot(ctx, node, key, 'default', false, null);
}
return function template(ctx, node, key = \\"\\") {
@@ -1274,7 +1274,7 @@ exports[`slots nested slots: evaluation context and parented relationship 3`] =
let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([], [b2]);
}
}"
@@ -1314,7 +1314,7 @@ exports[`slots no named slot content => just no children 2`] = `
let block1 = createBlock(\`<span><block-child-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'header', false, {});
const b2 = callSlot(ctx, node, key, 'header', false, null);
return block1([], [b2]);
}
}"
@@ -1345,7 +1345,7 @@ exports[`slots simple default slot 2`] = `
let block1 = createBlock(\`<span><block-child-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([], [b2]);
}
}"
@@ -1439,7 +1439,7 @@ exports[`slots simple default slot, variation 2`] = `
let { callSlot } = helpers;
return function template(ctx, node, key = \\"\\") {
return callSlot(ctx, node, key, 'default', false, {});
return callSlot(ctx, node, key, 'default', false, null);
}
}"
`;
@@ -1525,7 +1525,7 @@ exports[`slots slot and (inline) t-call 3`] = `
let block1 = createBlock(\`<span><block-child-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([], [b2]);
}
}"
@@ -1574,7 +1574,7 @@ exports[`slots slot and t-call 3`] = `
let block1 = createBlock(\`<span><block-child-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([], [b2]);
}
}"
@@ -1608,7 +1608,7 @@ exports[`slots slot and t-esc 2`] = `
let block1 = createBlock(\`<span><block-child-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([], [b2]);
}
}"
@@ -1644,7 +1644,7 @@ exports[`slots slot are properly rendered if inner props are changed 2`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([], [b2]);
}
}"
@@ -1689,7 +1689,7 @@ exports[`slots slot content has different key from other content -- dynamic slot
return function template(ctx, node, key = \\"\\") {
const b2 = component(\`Child\`, {parent: 'SlotDisplay'}, key + \`__1\`, node, ctx);
const slot1 = (ctx['slotName']);
const b3 = toggler(slot1, callSlot(ctx, node, key, slot1), true, {});
const b3 = toggler(slot1, callSlot(ctx, node, key, slot1), true, null);
return multi([b2, b3]);
}
}"
@@ -1733,7 +1733,7 @@ exports[`slots slot content has different key from other content -- static slot
return function template(ctx, node, key = \\"\\") {
const b2 = component(\`Child\`, {parent: 'SlotDisplay'}, key + \`__1\`, node, ctx);
const b3 = callSlot(ctx, node, key, 'default', false, {});
const b3 = callSlot(ctx, node, key, 'default', false, null);
return multi([b2, b3]);
}
}"
@@ -1785,7 +1785,7 @@ exports[`slots slot content is bound to caller (variation) 2`] = `
let block1 = createBlock(\`<span><block-child-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([], [b2]);
}
}"
@@ -1819,7 +1819,7 @@ exports[`slots slot content is bound to caller 2`] = `
let block1 = createBlock(\`<span><block-child-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([], [b2]);
}
}"
@@ -1851,7 +1851,7 @@ exports[`slots slot preserves properly parented relationship 2`] = `
let { callSlot } = helpers;
return function template(ctx, node, key = \\"\\") {
return callSlot(ctx, node, key, 'default', false, {});
return callSlot(ctx, node, key, 'default', false, null);
}
}"
`;
@@ -1906,7 +1906,7 @@ exports[`slots slot preserves properly parented relationship, even through t-cal
let { callSlot } = helpers;
return function template(ctx, node, key = \\"\\") {
return callSlot(ctx, node, key, 'default', false, {});
return callSlot(ctx, node, key, 'default', false, null);
}
}"
`;
@@ -1947,7 +1947,7 @@ exports[`slots slots and wrapper components 2`] = `
let block1 = createBlock(\`<a href=\\"abc\\"><block-child-0/></a>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([], [b2]);
}
}"
@@ -1982,7 +1982,7 @@ exports[`slots slots are properly bound to correct component 2`] = `
}
return function template(ctx, node, key = \\"\\") {
return callSlot(ctx, node, key, 'default', false, {}, defaultContent1);
return callSlot(ctx, node, key, 'default', false, null, defaultContent1);
}
}"
`;
@@ -2019,7 +2019,7 @@ exports[`slots slots are rendered with proper context 2`] = `
let block1 = createBlock(\`<span><block-child-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'footer', false, {});
const b2 = callSlot(ctx, node, key, 'footer', false, null);
return block1([], [b2]);
}
}"
@@ -2066,7 +2066,7 @@ exports[`slots slots are rendered with proper context, part 2 2`] = `
return function template(ctx, node, key = \\"\\") {
let attr1 = ctx['props'].to;
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([attr1], [b2]);
}
}"
@@ -2114,7 +2114,7 @@ exports[`slots slots are rendered with proper context, part 3 2`] = `
return function template(ctx, node, key = \\"\\") {
let attr1 = ctx['props'].to;
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([attr1], [b2]);
}
}"
@@ -2153,7 +2153,7 @@ exports[`slots slots are rendered with proper context, part 4 2`] = `
return function template(ctx, node, key = \\"\\") {
let attr1 = ctx['props'].to;
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([attr1], [b2]);
}
}"
@@ -2193,7 +2193,7 @@ exports[`slots slots in slots, with vars 2`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`);
function slot1(ctx, node, key = \\"\\") {
return callSlot(ctx, node, key, 'default', false, {});
return callSlot(ctx, node, key, 'default', false, null);
}
return function template(ctx, node, key = \\"\\") {
@@ -2212,7 +2212,7 @@ exports[`slots slots in slots, with vars 3`] = `
let block1 = createBlock(\`<span><block-child-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([], [b2]);
}
}"
@@ -2256,7 +2256,7 @@ exports[`slots slots in t-foreach and re-rendering 2`] = `
return function template(ctx, node, key = \\"\\") {
let txt1 = ctx['state'].val;
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([txt1], [b2]);
}
}"
@@ -2314,7 +2314,7 @@ exports[`slots slots in t-foreach in t-foreach 2`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([], [b2]);
}
}"
@@ -2361,7 +2361,7 @@ exports[`slots slots in t-foreach with t-set and re-rendering 2`] = `
return function template(ctx, node, key = \\"\\") {
let txt1 = ctx['state'].val;
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([txt1], [b2]);
}
}"
@@ -2397,7 +2397,7 @@ exports[`slots t-debug on a t-set-slot (defining a slot) 2`] = `
let block1 = createBlock(\`<span><block-child-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'content', false, {});
const b2 = callSlot(ctx, node, key, 'content', false, null);
return block1([], [b2]);
}
}"
@@ -2435,7 +2435,7 @@ exports[`slots t-set t-value in a slot 2`] = `
let block1 = createBlock(\`<span><block-child-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([], [b2]);
}
}"
@@ -2495,7 +2495,7 @@ exports[`slots t-slot in recursive templates 2`] = `
let block1 = createBlock(\`<wrapper><block-child-0/></wrapper>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([], [b2]);
}
}"
@@ -2533,7 +2533,7 @@ exports[`slots t-slot nested within another slot 2`] = `
}
function slot2(ctx, node, key = \\"\\") {
return callSlot(ctx, node, key, 'default', false, {});
return callSlot(ctx, node, key, 'default', false, null);
}
return function template(ctx, node, key = \\"\\") {
@@ -2552,7 +2552,7 @@ exports[`slots t-slot nested within another slot 3`] = `
let block1 = createBlock(\`<span id=\\"modal\\"><block-child-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([], [b2]);
}
}"
@@ -2567,7 +2567,7 @@ exports[`slots t-slot nested within another slot 4`] = `
let block1 = createBlock(\`<span id=\\"portal\\"><block-child-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([], [b2]);
}
}"
@@ -2614,7 +2614,7 @@ exports[`slots t-slot scope context 2`] = `
function slot1(ctx, node, key = \\"\\") {
let hdlr1 = [ctx['onClick'], ctx];
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([hdlr1], [b2]);
}
@@ -2631,7 +2631,7 @@ exports[`slots t-slot scope context 3`] = `
let { callSlot } = helpers;
return function template(ctx, node, key = \\"\\") {
return callSlot(ctx, node, key, 'default', false, {});
return callSlot(ctx, node, key, 'default', false, null);
}
}"
`;
@@ -2666,7 +2666,7 @@ exports[`slots t-slot within dynamic t-call 2`] = `
let block1 = createBlock(\`<div class=\\"slotted\\"><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callSlot(ctx, node, key, 'default', false, {});
const b2 = callSlot(ctx, node, key, 'default', false, null);
return block1([], [b2]);
}
}"
@@ -2725,7 +2725,7 @@ exports[`slots template can just return a slot 2`] = `
let { callSlot } = helpers;
return function template(ctx, node, key = \\"\\") {
return callSlot(ctx, node, key, 'default', false, {});
return callSlot(ctx, node, key, 'default', false, null);
}
}"
`;
@@ -246,7 +246,7 @@ exports[`t-on t-on on t-set-slots 2`] = `
let { callSlot } = helpers;
return function template(ctx, node, key = \\"\\") {
return callSlot(ctx, node, key, 'myslot', false, {});
return callSlot(ctx, node, key, 'myslot', false, null);
}
}"
`;
@@ -281,7 +281,7 @@ exports[`t-on t-on on t-slots 2`] = `
const b3 = text(ctx['state'].count);
const b4 = text(\`] \`);
const hdlr1 = [()=>this.state.count++, ctx];
const b5 = catcher1(callSlot(ctx, node, key, 'default', false, {}), [hdlr1]);
const b5 = catcher1(callSlot(ctx, node, key, 'default', false, null), [hdlr1]);
return multi([b2, b3, b4, b5]);
}
}"
@@ -81,7 +81,7 @@ exports[`t-set slots with a t-set with a component in body 2`] = `
return function template(ctx, node, key = \\"\\") {
const b2 = text(\`Child \`);
const b3 = callSlot(ctx, node, key, 'default', false, {});
const b3 = callSlot(ctx, node, key, 'default', false, null);
return multi([b2, b3]);
}
}"
@@ -136,7 +136,7 @@ exports[`t-set slots with an t-set with a component in body 2`] = `
return function template(ctx, node, key = \\"\\") {
const b2 = text(\`Blorg \`);
const b3 = callSlot(ctx, node, key, 'default', false, {});
const b3 = callSlot(ctx, node, key, 'default', false, null);
return multi([b2, b3]);
}
}"
@@ -185,7 +185,7 @@ exports[`t-set slots with an unused t-set with a component in body 2`] = `
return function template(ctx, node, key = \\"\\") {
const b2 = text(\`Child \`);
const b3 = callSlot(ctx, node, key, 'default', false, {});
const b3 = callSlot(ctx, node, key, 'default', false, null);
return multi([b2, b3]);
}
}"
+1 -1
View File
@@ -171,7 +171,7 @@ exports[`Portal Portal composed with t-slot 2`] = `
let { Portal, callSlot } = helpers;
function slot1(ctx, node, key = \\"\\") {
return callSlot(ctx, node, key, 'default', false, {});
return callSlot(ctx, node, key, 'default', false, null);
}
return function template(ctx, node, key = \\"\\") {