mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
1ae9d514b9
With this commit, component only render child components if they have different props (shallow equality). Otherwise, we trust the reactivity system to make sure that all impacted components are updated
377 lines
12 KiB
Plaintext
377 lines
12 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
exports[`t-set slot setted value (with t-set) not accessible with t-esc 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
let { isBoundary, withDefault, setContextValue, capture, markRaw } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><p><block-text-0/></p><block-child-0/><p><block-text-1/></p></div>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[isBoundary] = 1
|
|
setContextValue(ctx, \\"iter\\", 'inCall');
|
|
return text('');
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[isBoundary] = 1
|
|
setContextValue(ctx, \\"iter\\", 'source');
|
|
let txt1 = ctx['iter'];
|
|
const ctx1 = capture(ctx);
|
|
let b2 = component(\`Childcomp\`, {slots: markRaw({'default': {__render: slot1, __ctx: ctx1}})}, key + \`__1\`, node, ctx);
|
|
let txt2 = ctx['iter'];
|
|
return block1([txt1, txt2], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set slot setted value (with t-set) not accessible with t-esc 2`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
let { isBoundary, withDefault, setContextValue } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[isBoundary] = 1
|
|
let txt1 = ctx['iter'];
|
|
setContextValue(ctx, \\"iter\\", 'called');
|
|
let txt2 = ctx['iter'];
|
|
return block1([txt1, txt2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set slots with a t-set with a component in body 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
let { capture, isBoundary, withDefault, LazyValue, safeOutput, markRaw } = helpers;
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[isBoundary] = 1
|
|
ctx[\`v\`] = new LazyValue(value1, ctx, node);
|
|
let b3 = text(\` in slot \`);
|
|
let b4 = safeOutput(ctx['v']);
|
|
return multi([b3, b4]);
|
|
}
|
|
|
|
function value1(ctx, node, key = \\"\\") {
|
|
return component(\`C\`, {}, key + \`__1\`, node, ctx);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const ctx1 = capture(ctx);
|
|
return component(\`Child\`, {slots: markRaw({'default': {__render: slot1, __ctx: ctx1}})}, key + \`__2\`, node, ctx);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set slots with a t-set with a component in body 2`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
let { callSlot } = helpers;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b2 = text(\`Child \`);
|
|
let b3 = callSlot(ctx, node, key, 'default', false, {});
|
|
return multi([b2, b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set slots with a t-set with a component in body 3`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return text(\`C\`);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set slots with an t-set with a component in body 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
let { capture, isBoundary, withDefault, LazyValue, safeOutput, markRaw } = helpers;
|
|
|
|
let block4 = createBlock(\`<div>coffee</div>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[isBoundary] = 1
|
|
ctx[\`v\`] = new LazyValue(value1, ctx, node);
|
|
let b5 = text(\` tea \`);
|
|
let b6 = safeOutput(ctx['v']);
|
|
return multi([b5, b6]);
|
|
}
|
|
|
|
function value1(ctx, node, key = \\"\\") {
|
|
let b3 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
|
let b4 = block4();
|
|
return multi([b3, b4]);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const ctx1 = capture(ctx);
|
|
return component(\`Blorg\`, {slots: markRaw({'default': {__render: slot1, __ctx: ctx1}})}, key + \`__2\`, node, ctx);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set slots with an t-set with a component in body 2`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
let { callSlot } = helpers;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b2 = text(\`Blorg \`);
|
|
let b3 = callSlot(ctx, node, key, 'default', false, {});
|
|
return multi([b2, b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set slots with an t-set with a component in body 3`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return text(\`Child\`);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set slots with an unused t-set with a component in body 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
let { capture, isBoundary, withDefault, LazyValue, markRaw } = helpers;
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[isBoundary] = 1
|
|
ctx[\`v\`] = new LazyValue(value1, ctx, node);
|
|
return text(\` in slot \`);
|
|
}
|
|
|
|
function value1(ctx, node, key = \\"\\") {
|
|
return component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const ctx1 = capture(ctx);
|
|
return component(\`Child\`, {slots: markRaw({'default': {__render: slot1, __ctx: ctx1}})}, key + \`__2\`, node, ctx);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set slots with an unused t-set with a component in body 2`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
let { callSlot } = helpers;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b2 = text(\`Child \`);
|
|
let b3 = callSlot(ctx, node, key, 'default', false, {});
|
|
return multi([b2, b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set t-set can't alter component even if key in component 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
let { isBoundary, withDefault, setContextValue } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><p><block-text-0/></p><p><block-text-1/></p></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[isBoundary] = 1
|
|
let txt1 = ctx['iter'];
|
|
setContextValue(ctx, \\"iter\\", 5);
|
|
let txt2 = ctx['iter'];
|
|
return block1([txt1, txt2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set t-set can't alter component if key not in component 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
let { isBoundary, withDefault, setContextValue } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><p><block-text-0/></p><p><block-text-1/></p></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[isBoundary] = 1
|
|
let txt1 = ctx['iter'];
|
|
setContextValue(ctx, \\"iter\\", 5);
|
|
let txt2 = ctx['iter'];
|
|
return block1([txt1, txt2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set t-set in t-if 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
let { isBoundary, withDefault, setContextValue } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/><block-child-0/><block-child-0/><p><block-text-0/></p></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[isBoundary] = 1
|
|
setContextValue(ctx, \\"flag\\", ctx['state'].flag);
|
|
if (ctx['flag']==='if') {
|
|
setContextValue(ctx, \\"iter\\", 2);
|
|
} else if (ctx['flag']==='elif') {
|
|
setContextValue(ctx, \\"iter\\", 3);
|
|
} else {
|
|
setContextValue(ctx, \\"iter\\", 4);
|
|
}
|
|
let txt1 = ctx['iter'];
|
|
return block1([txt1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set t-set not altered by child comp 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
let { isBoundary, withDefault, setContextValue } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><p><block-text-0/></p><block-child-0/><p><block-text-1/></p></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[isBoundary] = 1
|
|
setContextValue(ctx, \\"iter\\", 'source');
|
|
let txt1 = ctx['iter'];
|
|
let b2 = component(\`Childcomp\`, {}, key + \`__1\`, node, ctx);
|
|
let txt2 = ctx['iter'];
|
|
return block1([txt1, txt2], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set t-set not altered by child comp 2`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
let { isBoundary, withDefault, setContextValue } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[isBoundary] = 1
|
|
let txt1 = ctx['iter'];
|
|
setContextValue(ctx, \\"iter\\", 'called');
|
|
let txt2 = ctx['iter'];
|
|
return block1([txt1, txt2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set t-set outside modified in t-if 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
let { isBoundary, withDefault, setContextValue } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/><block-child-0/><block-child-0/><p><block-text-0/></p></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[isBoundary] = 1
|
|
setContextValue(ctx, \\"iter\\", 0);
|
|
setContextValue(ctx, \\"flag\\", ctx['state'].flag);
|
|
if (ctx['flag']==='if') {
|
|
setContextValue(ctx, \\"iter\\", 2);
|
|
} else if (ctx['flag']==='elif') {
|
|
setContextValue(ctx, \\"iter\\", 3);
|
|
} else {
|
|
setContextValue(ctx, \\"iter\\", 4);
|
|
}
|
|
let txt1 = ctx['iter'];
|
|
return block1([txt1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set t-set with a component in body 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
let { isBoundary, withDefault, LazyValue, safeOutput } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><div><block-child-0/></div></div>\`);
|
|
|
|
function value1(ctx, node, key = \\"\\") {
|
|
return component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[isBoundary] = 1
|
|
ctx[\`v\`] = new LazyValue(value1, ctx, node);
|
|
let b3 = safeOutput(ctx['v']);
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set t-set with a component in body 2`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return text(\`Child\`);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set t-set with something in body 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
let { isBoundary, withDefault, LazyValue, safeOutput } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><div><block-child-0/></div></div>\`);
|
|
let block2 = createBlock(\`<p>coucou</p>\`);
|
|
|
|
function value1(ctx, node, key = \\"\\") {
|
|
return block2();
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[isBoundary] = 1
|
|
ctx[\`v\`] = new LazyValue(value1, ctx, node);
|
|
let b3 = safeOutput(ctx['v']);
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|