mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX][BREAKING] t-esc on component is not supported anymore
This commit is contained in:
committed by
Géry Debongnie
parent
cb0b525f32
commit
2806cda420
@@ -405,18 +405,15 @@ function parseTEscNode(node: Element, ctx: ParsingContext): AST | null {
|
|||||||
if (!ast) {
|
if (!ast) {
|
||||||
return tesc;
|
return tesc;
|
||||||
}
|
}
|
||||||
if (ast && ast.type === ASTType.DomNode) {
|
if (ast.type === ASTType.DomNode) {
|
||||||
return {
|
return {
|
||||||
...ast,
|
...ast,
|
||||||
ref,
|
ref,
|
||||||
content: [tesc],
|
content: [tesc],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (ast && ast.type === ASTType.TComponent) {
|
if (ast.type === ASTType.TComponent) {
|
||||||
return {
|
throw new Error("t-esc is not supported on Component nodes");
|
||||||
...ast,
|
|
||||||
slots: { default: tesc },
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
return tesc;
|
return tesc;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1082,14 +1082,7 @@ describe("qweb parser", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("component with t-esc", async () => {
|
test("component with t-esc", async () => {
|
||||||
expect(parse(`<MyComponent t-esc="someValue"/>`)).toEqual({
|
expect(() => parse(`<MyComponent t-esc="someValue"/>`)).toThrow("t-esc is not supported on Component nodes");
|
||||||
type: ASTType.TComponent,
|
|
||||||
name: "MyComponent",
|
|
||||||
dynamicProps: null,
|
|
||||||
props: {},
|
|
||||||
isDynamic: false,
|
|
||||||
slots: { default: { defaultValue: "", expr: "someValue", type: ASTType.TEsc } },
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("component with t-call", async () => {
|
test("component with t-call", async () => {
|
||||||
|
|||||||
@@ -1137,41 +1137,6 @@ exports[`slots slot and (inline) t-call 3`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`slots slot and (inline) t-esc 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 } = helpers;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let b2 = callSlot(ctx, node, key, 'default');
|
|
||||||
return block1([], [b2]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`slots slot and (inline) t-esc 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 } = helpers;
|
|
||||||
let assign = Object.assign;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
||||||
|
|
||||||
const slot2 = 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)}});
|
|
||||||
return block1([], [b3]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`slots slot and t-call 1`] = `
|
exports[`slots slot and t-call 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -1162,19 +1162,6 @@ describe("slots", () => {
|
|||||||
expect(fixture.innerHTML).toBe("<div><span>toph</span></div>");
|
expect(fixture.innerHTML).toBe("<div><span>toph</span></div>");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("slot and (inline) t-esc", async () => {
|
|
||||||
class Dialog extends Component {
|
|
||||||
static template = xml`<span><t t-slot="default"/></span>`;
|
|
||||||
}
|
|
||||||
class Parent extends Component {
|
|
||||||
static template = xml`<div><Dialog t-esc="'toph'"/></div>`;
|
|
||||||
static components = { Dialog };
|
|
||||||
}
|
|
||||||
await mount(Parent, fixture);
|
|
||||||
|
|
||||||
expect(fixture.innerHTML).toBe("<div><span>toph</span></div>");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("slot and t-call", async () => {
|
test("slot and t-call", async () => {
|
||||||
let sokka = xml`<p>sokka</p>`;
|
let sokka = xml`<p>sokka</p>`;
|
||||||
class Dialog extends Component {
|
class Dialog extends Component {
|
||||||
|
|||||||
Reference in New Issue
Block a user