mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
a51b286671
It is common in Owl components to have anonymous function as props. However, since each rendering create a different (but equivalent) closure, Owl will consider the props different, so will update the child component, but this is (often) not necessary. This commit will help reduce the problem by introducing a new `.alike` prop suffix, that will let Owl know that each version of that specific prop should be considered the same, so, will be ignored by the props comparison code. closes #1360
396 lines
13 KiB
Plaintext
396 lines
13 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
exports[`Reactivity: useState concurrent renderings 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(\`<span><block-text-0/><block-text-1/></span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let d1 = ctx['context'][ctx['props'].key].n;
|
|
let d2 = ctx['state'].x;
|
|
return block1([d1, d2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Reactivity: useState concurrent renderings 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(\`<p><block-child-0/></p>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b2 = component(\`ComponentC\`, {key: ctx['props'].key}, key + \`__1\`, node, ctx);
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Reactivity: useState concurrent renderings 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(\`<div><block-child-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b2 = component(\`ComponentB\`, {key: ctx['context'].key}, key + \`__1\`, node, ctx);
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Reactivity: useState destroyed component before being mounted is inactive 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, []);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b2;
|
|
if (ctx['state'].flag) {
|
|
b2 = comp1({}, key + \`__1\`, node, this, null);
|
|
}
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Reactivity: useState destroyed component before being mounted is inactive 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let txt1 = ctx['contextObj'].a;
|
|
return block1([txt1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Reactivity: useState destroyed component is inactive 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, []);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b2;
|
|
if (ctx['state'].flag) {
|
|
b2 = comp1({}, key + \`__1\`, node, this, null);
|
|
}
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Reactivity: useState destroyed component is inactive 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let txt1 = ctx['contextObj'].a;
|
|
return block1([txt1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Reactivity: useState one components can subscribe twice to same context 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let txt1 = ctx['contextObj1'].a;
|
|
let txt2 = ctx['contextObj2'].b;
|
|
return block1([txt1, txt2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Reactivity: useState parent and children subscribed to same context 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, []);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/><block-text-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b2 = comp1({}, key + \`__1\`, node, this, null);
|
|
let txt1 = ctx['contextObj'].b;
|
|
return block1([txt1], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Reactivity: useState parent and children subscribed to same context 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let txt1 = ctx['contextObj'].a;
|
|
return block1([txt1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Reactivity: useState several nodes on different level use same context 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(\`<div><block-text-0/> <block-text-1/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let d1 = ctx['contextObj'].a;
|
|
let d2 = ctx['contextObj'].b;
|
|
return block1([d1, d2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Reactivity: useState several nodes on different level use same context 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(\`<div><block-text-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let d1 = ctx['contextObj'].b;
|
|
return block1([d1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Reactivity: useState several nodes on different level use same context 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(\`<div><block-text-0/><block-child-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let d1 = ctx['contextObj'].a;
|
|
let b2 = component(\`L3A\`, {}, key + \`__1\`, node, ctx);
|
|
return block1([d1], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Reactivity: useState several nodes on different level use same context 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;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b2 = component(\`L2A\`, {}, key + \`__1\`, node, ctx);
|
|
let b3 = component(\`L2B\`, {}, key + \`__2\`, node, ctx);
|
|
return block1([], [b2, b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Reactivity: useState two components are updated in parallel 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, []);
|
|
const comp2 = app.createComponent(\`Child\`, true, false, false, []);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b2 = comp1({}, key + \`__1\`, node, this, null);
|
|
const b3 = comp2({}, key + \`__2\`, node, this, null);
|
|
return block1([], [b2, b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Reactivity: useState two components are updated in parallel 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let txt1 = ctx['contextObj'].value;
|
|
return block1([txt1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Reactivity: useState two components can subscribe to same context 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, []);
|
|
const comp2 = app.createComponent(\`Child\`, true, false, false, []);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b2 = comp1({}, key + \`__1\`, node, this, null);
|
|
const b3 = comp2({}, key + \`__2\`, node, this, null);
|
|
return block1([], [b2, b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Reactivity: useState two components can subscribe to same context 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let txt1 = ctx['contextObj'].value;
|
|
return block1([txt1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Reactivity: useState two independent components on different levels are updated in parallel 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, []);
|
|
const comp2 = app.createComponent(\`Parent\`, true, false, false, []);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b2 = comp1({}, key + \`__1\`, node, this, null);
|
|
const b3 = comp2({}, key + \`__2\`, node, this, null);
|
|
return block1([], [b2, b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Reactivity: useState two independent components on different levels are updated in parallel 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let txt1 = ctx['contextObj'].value;
|
|
return block1([txt1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Reactivity: useState two independent components on different levels are updated in parallel 3`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, []);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b2 = comp1({}, key + \`__1\`, node, this, null);
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Reactivity: useState useContext=useState hook is reactive, for one component 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let txt1 = ctx['contextObj'].value;
|
|
return block1([txt1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Reactivity: useState useless atoms should be deleted 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { prepareList, withKey } = helpers;
|
|
const comp1 = app.createComponent(\`Quantity\`, true, false, false, [\\"id\\"]);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/> Total: <block-text-0/> Count: <block-text-1/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
const [k_block2, v_block2, l_block2, c_block2] = prepareList(Object.keys(ctx['state']));;
|
|
for (let i1 = 0; i1 < l_block2; i1++) {
|
|
ctx[\`id\`] = v_block2[i1];
|
|
const key1 = ctx['id'];
|
|
c_block2[i1] = withKey(comp1({id: ctx['id']}, key + \`__1__\${key1}\`, node, this, null), key1);
|
|
}
|
|
ctx = ctx.__proto__;
|
|
const b2 = list(c_block2);
|
|
let txt1 = ctx['total'];
|
|
let txt2 = Object.keys(ctx['state']).length;
|
|
return block1([txt1, txt2], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Reactivity: useState useless atoms should be deleted 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let txt1 = ctx['state'].quantity;
|
|
return block1([txt1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Reactivity: useState very simple use, with initial value 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let txt1 = ctx['contextObj'].value;
|
|
return block1([txt1]);
|
|
}
|
|
}"
|
|
`;
|