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
Aaron Bohy
parent
db93ef08ff
commit
1761af9c24
@@ -405,18 +405,15 @@ function parseTEscNode(node: Element, ctx: ParsingContext): AST | null {
|
||||
if (!ast) {
|
||||
return tesc;
|
||||
}
|
||||
if (ast && ast.type === ASTType.DomNode) {
|
||||
if (ast.type === ASTType.DomNode) {
|
||||
return {
|
||||
...ast,
|
||||
ref,
|
||||
content: [tesc],
|
||||
};
|
||||
}
|
||||
if (ast && ast.type === ASTType.TComponent) {
|
||||
return {
|
||||
...ast,
|
||||
slots: { default: tesc },
|
||||
};
|
||||
if (ast.type === ASTType.TComponent) {
|
||||
throw new Error("t-esc is not supported on Component nodes");
|
||||
}
|
||||
return tesc;
|
||||
}
|
||||
|
||||
@@ -1082,14 +1082,7 @@ describe("qweb parser", () => {
|
||||
});
|
||||
|
||||
test("component with t-esc", async () => {
|
||||
expect(parse(`<MyComponent t-esc="someValue"/>`)).toEqual({
|
||||
type: ASTType.TComponent,
|
||||
name: "MyComponent",
|
||||
dynamicProps: null,
|
||||
props: {},
|
||||
isDynamic: false,
|
||||
slots: { default: { defaultValue: "", expr: "someValue", type: ASTType.TEsc } },
|
||||
});
|
||||
expect(() => parse(`<MyComponent t-esc="someValue"/>`)).toThrow("t-esc is not supported on Component nodes");
|
||||
});
|
||||
|
||||
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`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
|
||||
@@ -1162,19 +1162,6 @@ describe("slots", () => {
|
||||
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 () => {
|
||||
let sokka = xml`<p>sokka</p>`;
|
||||
class Dialog extends Component {
|
||||
|
||||
Reference in New Issue
Block a user