mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
0f2192604c
This commit reintroduces some tests for the t-set directive and make
them pass. For that, it was necessary to adapt the qweb compiler in
order to get the following behaviors:
A t-set can affect parent contexts (up to the first parent tagged as
boundary) when the key changed is found in one of the parent contexts.
Some context are marked as boundaries in such a way that
- rendering contexts (e.g. components) cannot be modified via a t-set.
- a t-set in a t-call body or in a called template can never change a
context above the t-call context.
Code prettification has been done.
Snapshots have been modified.
88 lines
3.2 KiB
Plaintext
88 lines
3.2 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
exports[`Memo if no prop change, prevent renderings from above 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 } = helpers;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return text(ctx['props'].value);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Memo if no prop change, prevent renderings from above 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 } = helpers;
|
|
let assign = Object.assign;
|
|
|
|
const slot2 = ctx => (node, key) => {
|
|
let b6 = text(ctx['state'].a);
|
|
let b7 = text(ctx['state'].b);
|
|
let b8 = text(ctx['state'].c);
|
|
return multi([b6, b7, b8]);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
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)}});
|
|
return multi([b2, b3, b4, b9]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Memo if no props, prevent renderings from above 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 } = helpers;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return text(ctx['props'].value);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Memo if no props, prevent renderings from above 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 } = helpers;
|
|
let assign = Object.assign;
|
|
|
|
const slot3 = ctx => (node, key) => {
|
|
return component(\`Child\`, {value: ctx['state'].value}, key + \`__4\`, 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)}});
|
|
return multi([b2, b4]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Memo if no props, prevent renderings from above (work with simple html) 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 } = helpers;
|
|
let assign = Object.assign;
|
|
|
|
const slot2 = 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)}});
|
|
return multi([b2, b4]);
|
|
}
|
|
}"
|
|
`;
|