mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
e4a0277f68
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.
467 lines
16 KiB
Plaintext
467 lines
16 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
exports[`Portal Portal composed with t-slot 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 block1 = createBlock(\`<div>child2</div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return block1();
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal Portal composed with t-slot 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) => {
|
|
return callSlot(ctx, node, key, 'default');
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}});
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal Portal composed with t-slot 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 } = helpers;
|
|
let assign = Object.assign;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
const slot2 = ctx => (node, key) => {
|
|
let h4 = [\`custom\`, ctx, '_handled'];
|
|
return assign(component(\`Child2\`, {}, key + \`__3\`, node, ctx), {handlers: [h4]});
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b3 = assign(component(\`Child\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}});
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal basic use of portal 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;
|
|
|
|
let block1 = createBlock(\`<div><span>1</span><block-child-0/></div>\`);
|
|
let block2 = createBlock(\`<p>2</p>\`);
|
|
|
|
const slot2 = ctx => (node, key) => {
|
|
return block2();
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b3 = assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}});
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal conditional use of Portal (with sub Component) 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 block1 = createBlock(\`<p><block-text-0/></p>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let d1 = ctx['props'].val;
|
|
return block1([d1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal conditional use of Portal (with sub Component) 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;
|
|
|
|
let block2 = createBlock(\`<span>1</span>\`);
|
|
|
|
const slot2 = ctx => (node, key) => {
|
|
return component(\`Child\`, {val: ctx['state'].val}, key + \`__3\`, node, ctx);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b2,b4;
|
|
b2 = block2();
|
|
if (ctx['state'].hasPortal) {
|
|
b4 = assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}});
|
|
}
|
|
return multi([b2, b4]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal conditional use of Portal 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;
|
|
|
|
let block2 = createBlock(\`<span>1</span>\`);
|
|
let block3 = createBlock(\`<p>2</p>\`);
|
|
|
|
const slot2 = ctx => (node, key) => {
|
|
return block3();
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b2,b4;
|
|
b2 = block2();
|
|
if (ctx['state'].hasPortal) {
|
|
b4 = assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}});
|
|
}
|
|
return multi([b2, b4]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal lifecycle hooks of portal sub component are properly called 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 block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let d1 = ctx['props'].val;
|
|
return block1([d1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal lifecycle hooks of portal sub component are properly called 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;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
const slot2 = ctx => (node, key) => {
|
|
return component(\`Child\`, {val: ctx['state'].val}, key + \`__3\`, node, ctx);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b3;
|
|
if (ctx['state'].hasChild) {
|
|
b3 = assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}});
|
|
}
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal portal could have dynamically no content 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;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
let block3 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
const slot2 = ctx => (node, key) => {
|
|
let b3;
|
|
if (ctx['state'].val) {
|
|
let d1 = ctx['state'].val;
|
|
b3 = block3([d1]);
|
|
}
|
|
return multi([b3]);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b4 = assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}});
|
|
return block1([], [b4]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal portal with child and props 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 block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let d1 = ctx['props'].val;
|
|
return block1([d1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal portal with child and props 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;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
const slot2 = ctx => (node, key) => {
|
|
return component(\`Child\`, {val: ctx['state'].val}, key + \`__3\`, node, ctx);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b3 = assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}});
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal portal with dynamic body 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;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
let block3 = createBlock(\`<span><block-text-0/></span>\`);
|
|
let block4 = createBlock(\`<div/>\`);
|
|
|
|
const slot2 = ctx => (node, key) => {
|
|
let b3,b4;
|
|
if (ctx['state'].val) {
|
|
let d1 = ctx['state'].val;
|
|
b3 = block3([d1]);
|
|
} else {
|
|
b4 = block4();
|
|
}
|
|
return multi([b3, b4]);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b5 = assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}});
|
|
return block1([], [b5]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal portal with many children 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;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
let block3 = createBlock(\`<div>1</div>\`);
|
|
let block4 = createBlock(\`<p>2</p>\`);
|
|
|
|
const slot2 = ctx => (node, key) => {
|
|
let b3 = block3();
|
|
let b4 = block4();
|
|
return multi([b3, b4]);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b5 = assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}});
|
|
return block1([], [b5]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal portal with no content 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;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
const slot2 = ctx => (node, key) => {
|
|
let b3;
|
|
if (false) {
|
|
b3 = text('ABC');
|
|
}
|
|
return multi([b3]);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b4 = assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}});
|
|
return block1([], [b4]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal portal with only text as content 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;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
const slot2 = ctx => (node, key) => {
|
|
return text('only text');
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b3 = assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}});
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal portal with target not in dom 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture } = helpers;
|
|
let assign = Object.assign;
|
|
|
|
let block1 = createBlock(\`<div><owl-child-0/></div>\`);
|
|
let block2 = createBlock(\`<div>2</div>\`);
|
|
|
|
const slot2 = ctx => (node, key) => {
|
|
return block2();
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b3 = assign(node.getChild(\`Portal\`, {target: '#does-not-exist'}, key + \`__1\`, ctx), {slots: {'default': slot2(ctx)}});
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal portal's parent's env is not polluted 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 block1 = createBlock(\`<button>child</button>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return block1();
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal portal's parent's env is not polluted 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;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
const slot2 = ctx => (node, key) => {
|
|
return component(\`Child\`, {}, key + \`__3\`, node, ctx);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b3 = assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}});
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal with target in template (after portal) 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;
|
|
|
|
let block1 = createBlock(\`<div><span>1</span><block-child-0/><div id=\\"local-target\\"/></div>\`);
|
|
let block2 = createBlock(\`<p>2</p>\`);
|
|
|
|
const slot2 = ctx => (node, key) => {
|
|
return block2();
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b3 = assign(component(\`Portal\`, {target: '#local-target'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}});
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal with target in template (before portal) 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;
|
|
|
|
let block1 = createBlock(\`<div><div id=\\"local-target\\"/><span>1</span><block-child-0/></div>\`);
|
|
let block2 = createBlock(\`<p>2</p>\`);
|
|
|
|
const slot2 = ctx => (node, key) => {
|
|
return block2();
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b3 = assign(component(\`Portal\`, {target: '#local-target'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}});
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal: UI/UX focus is kept across re-renders 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 block1 = createBlock(\`<input id=\\"target-me\\" block-attribute-0=\\"placeholder\\"/>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let d1 = ctx['props'].val;
|
|
return block1([d1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal: UI/UX focus is kept across re-renders 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;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
const slot2 = ctx => (node, key) => {
|
|
return component(\`Child\`, {val: ctx['state'].val}, key + \`__3\`, node, ctx);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b3 = assign(component(\`Portal\`, {target: '#outside'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}});
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|