Files
owl/tests/misc/__snapshots__/portal.test.ts.snap
T

523 lines
16 KiB
Plaintext
Raw Normal View History

2020-11-26 16:45:25 +01:00
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Portal Portal composed with t-slot 1`] = `
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
2020-11-26 16:45:25 +01:00
2021-12-20 11:19:59 +01:00
let block1 = createBlock(\`<div><block-child-0/></div>\`);
function slot1(ctx, node, key = \\"\\") {
return component(\`Child2\`, {customHandler: ctx['_handled']}, key + \`__1\`, node, ctx);
2021-12-20 11:19:59 +01:00
}
2020-11-26 16:45:25 +01:00
return function template(ctx, node, key = \\"\\") {
let b3 = component(\`Child\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx);
2021-12-20 11:19:59 +01:00
return block1([], [b3]);
2020-11-26 16:45:25 +01:00
}
}"
`;
exports[`Portal Portal composed with t-slot 2`] = `
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let { callSlot } = helpers;
2020-11-26 16:45:25 +01:00
function slot1(ctx, node, key = \\"\\") {
2021-11-19 13:43:21 +01:00
return callSlot(ctx, node, key, 'default', false, {});
2020-11-26 16:45:25 +01:00
}
return function template(ctx, node, key = \\"\\") {
return component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__1\`, node, ctx);
2020-11-26 16:45:25 +01:00
}
}"
`;
exports[`Portal Portal composed with t-slot 3`] = `
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
2020-11-26 16:45:25 +01:00
2021-12-20 11:19:59 +01:00
let block1 = createBlock(\`<div block-handler-0=\\"custom\\"><span id=\\"childSpan\\">child2</span></div>\`);
2020-11-26 16:45:25 +01:00
return function template(ctx, node, key = \\"\\") {
let hdlr1 = [ctx['onCustom'], ctx];
return block1([hdlr1]);
2020-11-26 16:45:25 +01:00
}
}"
`;
exports[`Portal basic use of portal 1`] = `
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
2020-11-26 16:45:25 +01:00
let block1 = createBlock(\`<div><span>1</span><block-child-0/></div>\`);
let block2 = createBlock(\`<p>2</p>\`);
function slot1(ctx, node, key = \\"\\") {
2020-11-26 16:45:25 +01:00
return block2();
}
return function template(ctx, node, key = \\"\\") {
let b3 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__1\`, node, ctx);
2020-11-26 16:45:25 +01:00
return block1([], [b3]);
}
}"
`;
2021-12-21 16:26:29 +01:00
exports[`Portal basic use of portal in dev mode 1`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let block1 = createBlock(\`<div><span>1</span><block-child-0/></div>\`);
let block2 = createBlock(\`<p>2</p>\`);
function slot1(ctx, node, key = \\"\\") {
return block2();
}
return function template(ctx, node, key = \\"\\") {
const props1 = {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}
helpers.validateProps(\`Portal\`, props1, ctx)
let b3 = component(\`Portal\`, props1, key + \`__1\`, node, ctx);
2021-12-21 16:26:29 +01:00
return block1([], [b3]);
}
}"
`;
2020-11-26 16:45:25 +01:00
exports[`Portal conditional use of Portal (with sub Component) 1`] = `
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
2020-11-26 16:45:25 +01:00
let block2 = createBlock(\`<span>1</span>\`);
function slot1(ctx, node, key = \\"\\") {
return component(\`Child\`, {val: ctx['state'].val}, key + \`__1\`, node, ctx);
2020-11-26 16:45:25 +01:00
}
return function template(ctx, node, key = \\"\\") {
let b2,b4;
b2 = block2();
if (ctx['state'].hasPortal) {
b4 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx);
2020-11-26 16:45:25 +01:00
}
return multi([b2, b4]);
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`Portal conditional use of Portal (with sub Component) 2`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let block1 = createBlock(\`<p><block-text-0/></p>\`);
return function template(ctx, node, key = \\"\\") {
let txt1 = ctx['props'].val;
return block1([txt1]);
2021-12-20 11:19:59 +01:00
}
}"
`;
2020-11-26 16:45:25 +01:00
exports[`Portal conditional use of Portal 1`] = `
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
2020-11-26 16:45:25 +01:00
let block2 = createBlock(\`<span>1</span>\`);
let block3 = createBlock(\`<p>2</p>\`);
function slot1(ctx, node, key = \\"\\") {
2020-11-26 16:45:25 +01:00
return block3();
}
return function template(ctx, node, key = \\"\\") {
let b2,b4;
b2 = block2();
if (ctx['state'].hasPortal) {
b4 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__1\`, node, ctx);
2020-11-26 16:45:25 +01:00
}
return multi([b2, b4]);
}
}"
`;
exports[`Portal lifecycle hooks of portal sub component are properly called 1`] = `
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
2020-11-26 16:45:25 +01:00
2021-12-20 11:19:59 +01:00
let block1 = createBlock(\`<div><block-child-0/></div>\`);
function slot1(ctx, node, key = \\"\\") {
return component(\`Child\`, {val: ctx['state'].val}, key + \`__1\`, node, ctx);
2021-12-20 11:19:59 +01:00
}
2020-11-26 16:45:25 +01:00
return function template(ctx, node, key = \\"\\") {
2021-12-20 11:19:59 +01:00
let b3;
if (ctx['state'].hasChild) {
b3 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx);
2021-12-20 11:19:59 +01:00
}
return block1([], [b3]);
2020-11-26 16:45:25 +01:00
}
}"
`;
exports[`Portal lifecycle hooks of portal sub component are properly called 2`] = `
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
2020-11-26 16:45:25 +01:00
2021-12-20 11:19:59 +01:00
let block1 = createBlock(\`<span><block-text-0/></span>\`);
2020-11-26 16:45:25 +01:00
return function template(ctx, node, key = \\"\\") {
let txt1 = ctx['props'].val;
return block1([txt1]);
2020-11-26 16:45:25 +01:00
}
}"
`;
exports[`Portal portal could have dynamically no content 1`] = `
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
2020-11-26 16:45:25 +01:00
let block1 = createBlock(\`<div><block-child-0/></div>\`);
let block3 = createBlock(\`<span><block-text-0/></span>\`);
function slot1(ctx, node, key = \\"\\") {
2020-11-26 16:45:25 +01:00
let b3;
if (ctx['state'].val) {
let txt1 = ctx['state'].val;
b3 = block3([txt1]);
2020-11-26 16:45:25 +01:00
}
return multi([b3]);
}
return function template(ctx, node, key = \\"\\") {
let b4 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__1\`, node, ctx);
2020-11-26 16:45:25 +01:00
return block1([], [b4]);
}
}"
`;
2021-10-21 10:13:08 +02:00
exports[`Portal portal destroys on crash 1`] = `
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
2021-10-21 10:13:08 +02:00
let block1 = createBlock(\`<div><block-child-0/></div>\`);
function slot1(ctx, node, key = \\"\\") {
return component(\`Child\`, {error: ctx['state'].error}, key + \`__1\`, node, ctx);
2021-10-21 10:13:08 +02:00
}
return function template(ctx, node, key = \\"\\") {
let b3 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx);
2021-10-21 10:13:08 +02:00
return block1([], [b3]);
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`Portal portal destroys on crash 2`] = `
2020-11-26 16:45:25 +01:00
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
2020-11-26 16:45:25 +01:00
let block1 = createBlock(\`<span><block-text-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
let txt1 = ctx['props'].error&&this.will.crash;
return block1([txt1]);
2020-11-26 16:45:25 +01:00
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`Portal portal with child and props 1`] = `
2020-11-26 16:45:25 +01:00
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
2020-11-26 16:45:25 +01:00
let block1 = createBlock(\`<div><block-child-0/></div>\`);
function slot1(ctx, node, key = \\"\\") {
return component(\`Child\`, {val: ctx['state'].val}, key + \`__1\`, node, ctx);
2020-11-26 16:45:25 +01:00
}
return function template(ctx, node, key = \\"\\") {
let b3 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx);
2020-11-26 16:45:25 +01:00
return block1([], [b3]);
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`Portal portal with child and props 2`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let block1 = createBlock(\`<span><block-text-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
let txt1 = ctx['props'].val;
return block1([txt1]);
2021-12-20 11:19:59 +01:00
}
}"
`;
2020-11-26 16:45:25 +01:00
exports[`Portal portal with dynamic body 1`] = `
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
2020-11-26 16:45:25 +01:00
let block1 = createBlock(\`<div><block-child-0/></div>\`);
let block3 = createBlock(\`<span><block-text-0/></span>\`);
let block4 = createBlock(\`<div/>\`);
function slot1(ctx, node, key = \\"\\") {
2020-11-26 16:45:25 +01:00
let b3,b4;
if (ctx['state'].val) {
let txt1 = ctx['state'].val;
b3 = block3([txt1]);
2020-11-26 16:45:25 +01:00
} else {
b4 = block4();
}
return multi([b3, b4]);
}
return function template(ctx, node, key = \\"\\") {
let b5 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__1\`, node, ctx);
2020-11-26 16:45:25 +01:00
return block1([], [b5]);
}
}"
`;
exports[`Portal portal with many children 1`] = `
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
2020-11-26 16:45:25 +01:00
let block1 = createBlock(\`<div><block-child-0/></div>\`);
let block3 = createBlock(\`<div>1</div>\`);
let block4 = createBlock(\`<p>2</p>\`);
function slot1(ctx, node, key = \\"\\") {
2020-11-26 16:45:25 +01:00
let b3 = block3();
let b4 = block4();
return multi([b3, b4]);
}
return function template(ctx, node, key = \\"\\") {
let b5 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__1\`, node, ctx);
2020-11-26 16:45:25 +01:00
return block1([], [b5]);
}
}"
`;
exports[`Portal portal with no content 1`] = `
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
2020-11-26 16:45:25 +01:00
let block1 = createBlock(\`<div><block-child-0/></div>\`);
function slot1(ctx, node, key = \\"\\") {
2020-11-26 16:45:25 +01:00
let b3;
if (false) {
b3 = text('ABC');
}
return multi([b3]);
}
return function template(ctx, node, key = \\"\\") {
let b4 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__1\`, node, ctx);
2020-11-26 16:45:25 +01:00
return block1([], [b4]);
}
}"
`;
exports[`Portal portal with only text as content 1`] = `
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
2020-11-26 16:45:25 +01:00
let block1 = createBlock(\`<div><block-child-0/></div>\`);
function slot1(ctx, node, key = \\"\\") {
2020-11-26 16:45:25 +01:00
return text('only text');
}
return function template(ctx, node, key = \\"\\") {
let b3 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__1\`, node, ctx);
2020-11-26 16:45:25 +01:00
return block1([], [b3]);
}
}"
`;
exports[`Portal portal with target not in dom 1`] = `
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
2020-11-26 16:45:25 +01:00
2021-11-14 15:39:03 +01:00
let block1 = createBlock(\`<div><block-child-0/></div>\`);
2020-11-26 16:45:25 +01:00
let block2 = createBlock(\`<div>2</div>\`);
function slot1(ctx, node, key = \\"\\") {
2020-11-26 16:45:25 +01:00
return block2();
}
return function template(ctx, node, key = \\"\\") {
let b3 = component(\`Portal\`, {target: '#does-not-exist',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__1\`, node, ctx);
2020-11-26 16:45:25 +01:00
return block1([], [b3]);
}
}"
`;
exports[`Portal portal's parent's env is not polluted 1`] = `
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
2020-11-26 16:45:25 +01:00
2021-12-20 11:19:59 +01:00
let block1 = createBlock(\`<div><block-child-0/></div>\`);
function slot1(ctx, node, key = \\"\\") {
return component(\`Child\`, {}, key + \`__1\`, node, ctx);
2021-12-20 11:19:59 +01:00
}
2020-11-26 16:45:25 +01:00
return function template(ctx, node, key = \\"\\") {
let b3 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx);
2021-12-20 11:19:59 +01:00
return block1([], [b3]);
2020-11-26 16:45:25 +01:00
}
}"
`;
exports[`Portal portal's parent's env is not polluted 2`] = `
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
2020-11-26 16:45:25 +01:00
2021-12-20 11:19:59 +01:00
let block1 = createBlock(\`<button>child</button>\`);
2020-11-26 16:45:25 +01:00
return function template(ctx, node, key = \\"\\") {
2021-12-20 11:19:59 +01:00
return block1();
2020-11-26 16:45:25 +01:00
}
}"
`;
exports[`Portal with target in template (after portal) 1`] = `
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
2020-11-26 16:45:25 +01:00
let block1 = createBlock(\`<div><span>1</span><block-child-0/><div id=\\"local-target\\"/></div>\`);
let block2 = createBlock(\`<p>2</p>\`);
function slot1(ctx, node, key = \\"\\") {
2020-11-26 16:45:25 +01:00
return block2();
}
return function template(ctx, node, key = \\"\\") {
let b3 = component(\`Portal\`, {target: '#local-target',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__1\`, node, ctx);
2020-11-26 16:45:25 +01:00
return block1([], [b3]);
}
}"
`;
exports[`Portal with target in template (before portal) 1`] = `
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
2020-11-26 16:45:25 +01:00
let block1 = createBlock(\`<div><div id=\\"local-target\\"/><span>1</span><block-child-0/></div>\`);
let block2 = createBlock(\`<p>2</p>\`);
function slot1(ctx, node, key = \\"\\") {
2020-11-26 16:45:25 +01:00
return block2();
}
return function template(ctx, node, key = \\"\\") {
let b3 = component(\`Portal\`, {target: '#local-target',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__1\`, node, ctx);
2020-11-26 16:45:25 +01:00
return block1([], [b3]);
}
}"
`;
2021-11-14 15:39:03 +01:00
exports[`Portal: Props validation target is mandatory 1`] = `
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
2021-11-14 15:39:03 +01:00
let block1 = createBlock(\`<div><block-child-0/></div>\`);
let block2 = createBlock(\`<div>2</div>\`);
function slot1(ctx, node, key = \\"\\") {
2021-11-14 15:39:03 +01:00
return block2();
}
return function template(ctx, node, key = \\"\\") {
const props1 = {slots: {'default': {__render: slot1, __ctx: ctx}}}
helpers.validateProps(\`Portal\`, props1, ctx)
let b3 = component(\`Portal\`, props1, key + \`__1\`, node, ctx);
2021-11-14 15:39:03 +01:00
return block1([], [b3]);
}
}"
`;
exports[`Portal: Props validation target is not list 1`] = `
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
2021-11-14 15:39:03 +01:00
let block1 = createBlock(\`<div><block-child-0/></div>\`);
let block2 = createBlock(\`<div>2</div>\`);
function slot1(ctx, node, key = \\"\\") {
2021-11-14 15:39:03 +01:00
return block2();
}
return function template(ctx, node, key = \\"\\") {
const props1 = {target: ['body'],slots: {'default': {__render: slot1, __ctx: ctx}}}
helpers.validateProps(\`Portal\`, props1, ctx)
let b3 = component(\`Portal\`, props1, key + \`__1\`, node, ctx);
2021-11-14 15:39:03 +01:00
return block1([], [b3]);
}
}"
`;
2020-11-26 16:45:25 +01:00
exports[`Portal: UI/UX focus is kept across re-renders 1`] = `
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
2020-11-26 16:45:25 +01:00
2021-12-20 11:19:59 +01:00
let block1 = createBlock(\`<div><block-child-0/></div>\`);
function slot1(ctx, node, key = \\"\\") {
return component(\`Child\`, {val: ctx['state'].val}, key + \`__1\`, node, ctx);
2021-12-20 11:19:59 +01:00
}
2020-11-26 16:45:25 +01:00
return function template(ctx, node, key = \\"\\") {
let b3 = component(\`Portal\`, {target: '#outside',slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__2\`, node, ctx);
2021-12-20 11:19:59 +01:00
return block1([], [b3]);
2020-11-26 16:45:25 +01:00
}
}"
`;
exports[`Portal: UI/UX focus is kept across re-renders 2`] = `
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
2020-11-26 16:45:25 +01:00
2021-12-20 11:19:59 +01:00
let block1 = createBlock(\`<input id=\\"target-me\\" block-attribute-0=\\"placeholder\\"/>\`);
2020-11-26 16:45:25 +01:00
return function template(ctx, node, key = \\"\\") {
let attr1 = ctx['props'].val;
return block1([attr1]);
2020-11-26 16:45:25 +01:00
}
}"
`;