mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
df59ec49ae
t-call-context is a feature that's supposed to mask the rendering context completely, but currently the component remains available through `this`. This commit stops treating `this` as a reserved word, so that it's compiled to a lookup in the rendering context, and adds `this` to the rendering context when binding the component's rendering function. With these changes, `this` behaves the same as before when outside a t-call-context, but when the rendering context is overriden, the template can no longer access `this`. `this` still represents the instance of the component inside of the rendering function since it's needed by owl internally. A side-effect of this change is that now the rendering context is no longer the instance of the component by default, but is always an object with the component in its prototype chain. This was already the case before in some contexts (eg inside t-foreach, or inside components with a t-set/t-call anywhere in its template). This can cause issues in rare cases when a component method was called directly on the rendering context, as before this change, the method's bound this would be the component instance (except in a t-foreach, component with a t-set/t-call, etc), while after this change it is now never the component instance. When the method only reads on `this` there is no issue as all the components properties are available on the rendering contexts, but setting a value on `this` will write on the rendering context and not the component which is likely a mistake. While this is a breaking change, simply adding a t-set/t-call to any template would break components that would be broken by this change, with this in mind we decided to make this change anyway so that developers get the error as early as possible in the development cycle rather than having a seemingly inocuous change break code under them.
1002 lines
32 KiB
Plaintext
1002 lines
32 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
exports[`Portal Add and remove portals 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { prepareList, capture, withKey } = helpers;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
const b3 = text(\` Portal\`);
|
|
const b4 = text(ctx['portalId']);
|
|
return multi([b3, b4]);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
const [k_block1, v_block1, l_block1, c_block1] = prepareList(ctx['portalIds']);;
|
|
for (let i1 = 0; i1 < l_block1; i1++) {
|
|
ctx[\`portalId\`] = v_block1[i1];
|
|
const key1 = ctx['portalId'];
|
|
const ctx1 = capture(ctx);
|
|
c_block1[i1] = withKey(comp1({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx1}}}, key + \`__1__\${key1}\`, node, ctx, Portal), key1);
|
|
}
|
|
return list(c_block1);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal Add and remove portals on div 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { prepareList, capture, withKey } = helpers;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
let block2 = createBlock(\`<div> Portal<block-text-0/></div>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
let txt1 = ctx['portalId'];
|
|
return block2([txt1]);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
const [k_block1, v_block1, l_block1, c_block1] = prepareList(ctx['portalIds']);;
|
|
for (let i1 = 0; i1 < l_block1; i1++) {
|
|
ctx[\`portalId\`] = v_block1[i1];
|
|
const key1 = ctx['portalId'];
|
|
const ctx1 = capture(ctx);
|
|
c_block1[i1] = withKey(comp1({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx1}}}, key + \`__1__\${key1}\`, node, ctx, Portal), key1);
|
|
}
|
|
return list(c_block1);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal Add and remove portals with t-foreach 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { prepareList, capture, withKey } = helpers;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
let block2 = createBlock(\`<div><block-text-0/><block-child-0/></div>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
const b4 = text(\` Portal\`);
|
|
const b5 = text(ctx['portalId']);
|
|
return multi([b4, b5]);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
const [k_block1, v_block1, l_block1, c_block1] = prepareList(ctx['portalIds']);;
|
|
for (let i1 = 0; i1 < l_block1; i1++) {
|
|
ctx[\`portalId\`] = v_block1[i1];
|
|
const key1 = ctx['portalId'];
|
|
let txt1 = ctx['portalId'];
|
|
const ctx1 = capture(ctx);
|
|
const b6 = comp1({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx1}}}, key + \`__1__\${key1}\`, node, ctx, Portal);
|
|
c_block1[i1] = withKey(block2([txt1], [b6]), key1);
|
|
}
|
|
return list(c_block1);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal Add and remove portals with t-foreach and destroy 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { prepareList, capture, withKey } = helpers;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
let block2 = createBlock(\`<div><block-text-0/><block-child-0/></div>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
const b4 = text(\` Portal\`);
|
|
const b5 = text(ctx['portalId']);
|
|
return multi([b4, b5]);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
const [k_block1, v_block1, l_block1, c_block1] = prepareList(ctx['portalIds']);;
|
|
for (let i1 = 0; i1 < l_block1; i1++) {
|
|
ctx[\`portalId\`] = v_block1[i1];
|
|
const key1 = ctx['portalId'];
|
|
let txt1 = ctx['portalId'];
|
|
const ctx1 = capture(ctx);
|
|
const b6 = comp1({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx1}}}, key + \`__1__\${key1}\`, node, ctx, Portal);
|
|
c_block1[i1] = withKey(block2([txt1], [b6]), key1);
|
|
}
|
|
return list(c_block1);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal Add and remove portals with t-foreach inside div 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { prepareList, capture, withKey } = helpers;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
let block3 = createBlock(\`<div><block-text-0/><block-child-0/></div>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
const b5 = text(\` Portal\`);
|
|
const b6 = text(ctx['portalId']);
|
|
return multi([b5, b6]);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['portalIds']);;
|
|
for (let i1 = 0; i1 < l_block2; i1++) {
|
|
ctx[\`portalId\`] = v_block2[i1];
|
|
const key1 = ctx['portalId'];
|
|
let txt1 = ctx['portalId'];
|
|
const ctx1 = capture(ctx);
|
|
const b7 = comp1({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx1}}}, key + \`__1__\${key1}\`, node, ctx, Portal);
|
|
c_block2[i1] = withKey(block3([txt1], [b7]), key1);
|
|
}
|
|
const b2 = list(c_block2);
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal Child and Portal 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, true);
|
|
|
|
let block3 = createBlock(\`<div class=\\"portal\\"/>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b2 = comp1({}, key + \`__1\`, node, this, null);
|
|
const b3 = block3();
|
|
return multi([b2, b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal Child and Portal 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
let block2 = createBlock(\`<span>child</span>\`);
|
|
let block3 = createBlock(\`<span>portal</span>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
return block3();
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b2 = block2();
|
|
const b4 = comp1({target: '.portal',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__1\`, node, ctx, Portal);
|
|
return multi([b2, b4]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal Portal composed with t-slot 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { markRaw } = helpers;
|
|
const comp1 = app.createComponent(\`Child2\`, true, false, false, false);
|
|
const comp2 = app.createComponent(\`Child\`, true, true, false, true);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
return comp1({customHandler: ctx['_handled']}, key + \`__1\`, node, this, null);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b3 = comp2({slots: markRaw({'default': {__render: slot1.bind(this), __ctx: ctx}})}, key + \`__2\`, node, this, null);
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal Portal composed with t-slot 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { callSlot } = helpers;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
return callSlot(ctx, node, key, 'default', false, {});
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return comp1({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__1\`, node, ctx, Portal);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal Portal composed with t-slot 3`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div block-handler-0=\\"custom\\"><span id=\\"childSpan\\">child2</span></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let hdlr1 = [ctx['onCustom'], ctx];
|
|
return block1([hdlr1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal basic use of portal 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
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 b3 = comp1({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__1\`, node, ctx, Portal);
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal basic use of portal in dev mode 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
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 b3 = comp1({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__1\`, node, ctx, Portal);
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal basic use of portal on div 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
let block1 = createBlock(\`<div><span>1</span><block-child-0/></div>\`);
|
|
let block2 = createBlock(\`<div><p>2</p></div>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
return block2();
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b3 = comp1({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__1\`, node, ctx, Portal);
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal basic use of portal, variation 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
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 b3 = comp1({target: ctx['target'],slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__1\`, node, ctx, Portal);
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal conditional use of Portal (with sub Component) 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, false);
|
|
const comp2 = app.createComponent(null, false, true, false, false);
|
|
|
|
let block2 = createBlock(\`<span>1</span>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
return comp1({val: ctx['state'].val}, key + \`__1\`, node, this, null);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b2,b4;
|
|
b2 = block2();
|
|
if (ctx['state'].hasPortal) {
|
|
b4 = comp2({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__2\`, node, ctx, Portal);
|
|
}
|
|
return multi([b2, b4]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal conditional use of Portal (with sub Component) 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<p><block-text-0/></p>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let txt1 = ctx['props'].val;
|
|
return block1([txt1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal conditional use of Portal 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
let block2 = createBlock(\`<span>1</span>\`);
|
|
let block3 = createBlock(\`<p>2</p>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
return block3();
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b2,b4;
|
|
b2 = block2();
|
|
if (ctx['state'].hasPortal) {
|
|
b4 = comp1({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__1\`, node, ctx, Portal);
|
|
}
|
|
return multi([b2, b4]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal conditional use of Portal with child and div 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, true);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b2;
|
|
if (ctx['state'].hasPortal) {
|
|
b2 = comp1({}, key + \`__1\`, node, this, null);
|
|
}
|
|
return multi([b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal conditional use of Portal with child and div 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { prepareList, capture, withKey } = helpers;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
let block1 = createBlock(\`<div><span>hasPortal</span><block-child-0/></div>\`);
|
|
let block3 = createBlock(\`<p>thePortal</p>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
return block3();
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
const [k_block2, v_block2, l_block2, c_block2] = prepareList([1]);;
|
|
for (let i1 = 0; i1 < l_block2; i1++) {
|
|
ctx[\`elem\`] = v_block2[i1];
|
|
const key1 = ctx['elem'];
|
|
const ctx1 = capture(ctx);
|
|
c_block2[i1] = withKey(comp1({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx1}}}, key + \`__1__\${key1}\`, node, ctx, Portal), key1);
|
|
}
|
|
const b2 = list(c_block2);
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal conditional use of Portal with child and div, variation 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, true);
|
|
|
|
let block2 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b2;
|
|
if (ctx['state'].hasPortal) {
|
|
const b3 = comp1({}, key + \`__1\`, node, this, null);
|
|
b2 = block2([], [b3]);
|
|
}
|
|
return multi([b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal conditional use of Portal with child and div, variation 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { prepareList, capture, withKey } = helpers;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
let block2 = createBlock(\`<span>hasPortal</span>\`);
|
|
let block4 = createBlock(\`<p>thePortal</p>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
return block4();
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b2 = block2();
|
|
ctx = Object.create(ctx);
|
|
const [k_block3, v_block3, l_block3, c_block3] = prepareList([1]);;
|
|
for (let i1 = 0; i1 < l_block3; i1++) {
|
|
ctx[\`elem\`] = v_block3[i1];
|
|
const key1 = ctx['elem'];
|
|
const ctx1 = capture(ctx);
|
|
c_block3[i1] = withKey(comp1({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx1}}}, key + \`__1__\${key1}\`, node, ctx, Portal), key1);
|
|
}
|
|
const b3 = list(c_block3);
|
|
return multi([b2, b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal conditional use of Portal with div 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
let block2 = createBlock(\`<div><span>hasPortal</span><block-child-0/></div>\`);
|
|
let block3 = createBlock(\`<p>thePortal</p>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
return block3();
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b2;
|
|
if (ctx['state'].hasPortal) {
|
|
const b4 = comp1({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__1\`, node, ctx, Portal);
|
|
b2 = block2([], [b4]);
|
|
}
|
|
return multi([b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal lifecycle hooks of portal sub component are properly called 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, false);
|
|
const comp2 = app.createComponent(null, false, true, false, false);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/><block-child-0/></div>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
return comp1({val: ctx['state'].val}, key + \`__1\`, node, this, null);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b3;
|
|
if (ctx['state'].hasChild) {
|
|
b3 = comp2({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__2\`, node, ctx, Portal);
|
|
}
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal lifecycle hooks of portal sub component are properly called 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['props'].val;
|
|
return block1([txt1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal portal and Child 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, true);
|
|
|
|
let block2 = createBlock(\`<div class=\\"portal\\"/>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b2 = block2();
|
|
const b3 = comp1({}, key + \`__1\`, node, this, null);
|
|
return multi([b2, b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal portal and Child 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
let block2 = createBlock(\`<span>child</span>\`);
|
|
let block3 = createBlock(\`<span>portal</span>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
return block3();
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b2 = block2();
|
|
const b4 = comp1({target: '.portal',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__1\`, node, ctx, Portal);
|
|
return multi([b2, b4]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal portal could have dynamically no content 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
let block3 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
let b3;
|
|
if (ctx['state'].val) {
|
|
let txt1 = ctx['state'].val;
|
|
b3 = block3([txt1]);
|
|
}
|
|
return multi([b3]);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b4 = comp1({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__1\`, node, ctx, Portal);
|
|
return block1([], [b4]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal portal destroys on crash 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, false);
|
|
const comp2 = app.createComponent(null, false, true, false, false);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
return comp1({error: ctx['state'].error}, key + \`__1\`, node, this, null);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b3 = comp2({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__2\`, node, ctx, Portal);
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal portal destroys on crash 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['props'].error&&ctx['this'].will.crash;
|
|
return block1([txt1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal portal with child and props 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, false);
|
|
const comp2 = app.createComponent(null, false, true, false, false);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
return comp1({val: ctx['state'].val}, key + \`__1\`, node, this, null);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b3 = comp2({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__2\`, node, ctx, Portal);
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal portal with child and props 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['props'].val;
|
|
return block1([txt1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal portal with dynamic body 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
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 = \\"\\") {
|
|
let b3,b4;
|
|
if (ctx['state'].val) {
|
|
let txt1 = ctx['state'].val;
|
|
b3 = block3([txt1]);
|
|
} else {
|
|
b4 = block4();
|
|
}
|
|
return multi([b3, b4]);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b5 = comp1({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__1\`, node, ctx, Portal);
|
|
return block1([], [b5]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal portal with many children 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
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 = \\"\\") {
|
|
const b3 = block3();
|
|
const b4 = block4();
|
|
return multi([b3, b4]);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b5 = comp1({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__1\`, node, ctx, Portal);
|
|
return block1([], [b5]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal portal with no content 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
let b3;
|
|
if (false) {
|
|
b3 = text('ABC');
|
|
}
|
|
return multi([b3]);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b4 = comp1({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__1\`, node, ctx, Portal);
|
|
return block1([], [b4]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal portal with only text as content 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
return text('only text');
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b3 = comp1({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__1\`, node, ctx, Portal);
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal portal with target not in dom 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
let block2 = createBlock(\`<div>2</div>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
return block2();
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b3 = comp1({target: '#does-not-exist',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__1\`, node, ctx, Portal);
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal portal's parent's env is not polluted 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, true);
|
|
const comp2 = app.createComponent(null, false, true, false, false);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
return comp1({}, key + \`__1\`, node, this, null);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b3 = comp2({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__2\`, node, ctx, Portal);
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal portal's parent's env is not polluted 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<button>child</button>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return block1();
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal simple catchError with portal 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const comp1 = app.createComponent(\`Boom\`, true, false, false, true);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b2,b3;
|
|
if (ctx['error']) {
|
|
b2 = text(\`Error\`);
|
|
} else {
|
|
b3 = comp1({}, key + \`__1\`, node, this, null);
|
|
}
|
|
return block1([], [b2, b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal simple catchError with portal 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
let block1 = createBlock(\`<div><span>1</span><block-child-0/></div>\`);
|
|
let block2 = createBlock(\`<p><block-text-0/></p>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
let txt1 = ctx['a'].b.c;
|
|
return block2([txt1]);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b3 = comp1({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__1\`, node, ctx, Portal);
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal with target in template (after portal) 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
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 = \\"\\") {
|
|
return block2();
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b3 = comp1({target: '#local-target',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__1\`, node, ctx, Portal);
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal with target in template (before portal) 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
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 = \\"\\") {
|
|
return block2();
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b3 = comp1({target: '#local-target',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__1\`, node, ctx, Portal);
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal: Props validation target must be a valid selector 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
let block2 = createBlock(\`<div>2</div>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
return block2();
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b3 = comp1({target: ' ',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__1\`, node, ctx, Portal);
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal: Props validation target must be a valid selector 2 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(null, false, true, false, false);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
let block2 = createBlock(\`<div>2</div>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
return block2();
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b3 = comp1({target: 'aa',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__1\`, node, ctx, Portal);
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal: UI/UX focus is kept across re-renders 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const Portal = app.Portal;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, false);
|
|
const comp2 = app.createComponent(null, false, true, false, false);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
return comp1({val: ctx['state'].val}, key + \`__1\`, node, this, null);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b3 = comp2({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__2\`, node, ctx, Portal);
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`Portal: UI/UX focus is kept across re-renders 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<input id=\\"target-me\\" block-attribute-0=\\"placeholder\\"/>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let attr1 = ctx['props'].val;
|
|
return block1([attr1]);
|
|
}
|
|
}"
|
|
`;
|