mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] t-call-context: fix capture making component available in ctx
Previously, when using a component with a slot within a t-call with t-call-context, the component would become available again inside the slot despite the t-call-context. This was caused by the fact that the capture helper function creates an object with the component as its prototype which is incorrect. It should just use the previous context as its prototype.
This commit is contained in:
committed by
Géry Debongnie
parent
39329f80b2
commit
3d40533de1
@@ -54,7 +54,7 @@ exports[`slots can define and call slots 1`] = `
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
const b4 = comp1({slots: markRaw({'header': {__render: slot1.bind(this), __ctx: ctx1}, 'footer': {__render: slot2.bind(this), __ctx: ctx1}})}, key + \`__1\`, node, this, null);
|
||||
return block1([], [b4]);
|
||||
}
|
||||
@@ -89,7 +89,7 @@ exports[`slots can define and call slots with bound params 1`] = `
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
return comp1({slots: markRaw({'abc': {__render: slot1.bind(this), __ctx: ctx1, getValue: bind(this, ctx['getValue'])}})}, key + \`__1\`, node, this, null);
|
||||
}
|
||||
}"
|
||||
@@ -129,7 +129,7 @@ exports[`slots can define and call slots with params 1`] = `
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
const b4 = comp1({slots: markRaw({'header': {__render: slot1.bind(this), __ctx: ctx1, param: ctx['var']}, 'footer': {__render: slot2.bind(this), __ctx: ctx1, param: '5'}})}, key + \`__1\`, node, this, null);
|
||||
return block1([], [b4]);
|
||||
}
|
||||
@@ -363,7 +363,7 @@ exports[`slots default content is not rendered if named slot is provided 1`] = `
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
const b3 = comp1({slots: markRaw({'header': {__render: slot1.bind(this), __ctx: ctx1}})}, key + \`__1\`, node, this, null);
|
||||
return block1([], [b3]);
|
||||
}
|
||||
@@ -442,7 +442,7 @@ exports[`slots default slot next to named slot, with default content 1`] = `
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
const b3 = comp1({slots: markRaw({'footer': {__render: slot1.bind(this), __ctx: ctx1}})}, key + \`__1\`, node, this, null);
|
||||
return block1([], [b3]);
|
||||
}
|
||||
@@ -619,7 +619,7 @@ exports[`slots dynamic slot in multiple locations 1`] = `
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
return comp2({location: ctx['state'].location,slots: markRaw({'coffee': {__render: slot1.bind(this), __ctx: ctx1}})}, key + \`__2\`, node, this, null);
|
||||
}
|
||||
}"
|
||||
@@ -685,7 +685,7 @@ exports[`slots dynamic t-slot call 1`] = `
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
const b6 = comp1({slots: markRaw({'slot1': {__render: slot1.bind(this), __ctx: ctx1}, 'slot2': {__render: slot2.bind(this), __ctx: ctx1}})}, key + \`__1\`, node, this, null);
|
||||
return block1([], [b6]);
|
||||
}
|
||||
@@ -732,7 +732,7 @@ exports[`slots dynamic t-slot call with default 1`] = `
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
const b6 = comp1({slots: markRaw({'slot1': {__render: slot1.bind(this), __ctx: ctx1}, 'slot2': {__render: slot2.bind(this), __ctx: ctx1}})}, key + \`__1\`, node, this, null);
|
||||
return block1([], [b6]);
|
||||
}
|
||||
@@ -865,7 +865,7 @@ exports[`slots mix of slots, t-call, t-call with body, and giving own props chil
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
return comp1({slots: markRaw({'default': {__render: slot1.bind(this), __ctx: ctx1}})}, key + \`__2\`, node, this, null);
|
||||
}
|
||||
}"
|
||||
@@ -991,7 +991,7 @@ exports[`slots multiple roots are allowed in a named slot 1`] = `
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
const b5 = comp1({slots: markRaw({'content': {__render: slot1.bind(this), __ctx: ctx1}})}, key + \`__1\`, node, this, null);
|
||||
return block1([], [b5]);
|
||||
}
|
||||
@@ -1031,7 +1031,7 @@ exports[`slots multiple slots containing components 1`] = `
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
return comp3({slots: markRaw({'s1': {__render: slot1.bind(this), __ctx: ctx1}, 's2': {__render: slot2.bind(this), __ctx: ctx1}})}, key + \`__3\`, node, this, null);
|
||||
}
|
||||
}"
|
||||
@@ -1085,7 +1085,7 @@ exports[`slots named slot inside slot 1`] = `
|
||||
}
|
||||
|
||||
function slot2(ctx, node, key = \\"\\") {
|
||||
const ctx2 = capture(ctx, this);
|
||||
const ctx2 = capture(ctx);
|
||||
return comp1({slots: markRaw({'brol': {__render: slot3.bind(this), __ctx: ctx2}})}, key + \`__1\`, node, this, null);
|
||||
}
|
||||
|
||||
@@ -1095,7 +1095,7 @@ exports[`slots named slot inside slot 1`] = `
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
const b5 = comp2({slots: markRaw({'brol': {__render: slot1.bind(this), __ctx: ctx1}, 'default': {__render: slot2.bind(this), __ctx: ctx1}})}, key + \`__2\`, node, this, null);
|
||||
return block1([], [b5]);
|
||||
}
|
||||
@@ -1136,7 +1136,7 @@ exports[`slots named slot inside slot, part 3 1`] = `
|
||||
}
|
||||
|
||||
function slot2(ctx, node, key = \\"\\") {
|
||||
const ctx2 = capture(ctx, this);
|
||||
const ctx2 = capture(ctx);
|
||||
return comp1({slots: markRaw({'brol': {__render: slot3.bind(this), __ctx: ctx2}})}, key + \`__1\`, node, this, null);
|
||||
}
|
||||
|
||||
@@ -1146,7 +1146,7 @@ exports[`slots named slot inside slot, part 3 1`] = `
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
const b5 = comp2({slots: markRaw({'brol': {__render: slot1.bind(this), __ctx: ctx1}, 'default': {__render: slot2.bind(this), __ctx: ctx1}})}, key + \`__2\`, node, this, null);
|
||||
return block1([], [b5]);
|
||||
}
|
||||
@@ -1221,7 +1221,7 @@ exports[`slots named slots inside slot, again 1`] = `
|
||||
}
|
||||
|
||||
function slot2(ctx, node, key = \\"\\") {
|
||||
const ctx2 = capture(ctx, this);
|
||||
const ctx2 = capture(ctx);
|
||||
return comp1({slots: markRaw({'brol2': {__render: slot3.bind(this), __ctx: ctx2}})}, key + \`__1\`, node, this, null);
|
||||
}
|
||||
|
||||
@@ -1231,7 +1231,7 @@ exports[`slots named slots inside slot, again 1`] = `
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
const b5 = comp2({slots: markRaw({'brol1': {__render: slot1.bind(this), __ctx: ctx1}, 'default': {__render: slot2.bind(this), __ctx: ctx1}})}, key + \`__2\`, node, this, null);
|
||||
return block1([], [b5]);
|
||||
}
|
||||
@@ -1569,7 +1569,7 @@ exports[`slots simple dynamic slot with slot scope 1`] = `
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
return comp1({slots: markRaw({'slotName': {__render: slot1.bind(this), __ctx: ctx1, __scope: \\"slotScope\\"}})}, key + \`__1\`, node, this, null);
|
||||
}
|
||||
}"
|
||||
@@ -1599,7 +1599,7 @@ exports[`slots simple named and empty slot -- 2 1`] = `
|
||||
const comp1 = app.createComponent(\`Child\`, true, true, false, true);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
return comp1({slots: markRaw({'myEmptySlot': {myProp: 'myProp text'}})}, key + \`__1\`, node, this, null);
|
||||
}
|
||||
}"
|
||||
@@ -1636,7 +1636,7 @@ exports[`slots simple named and empty slot 1`] = `
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
return comp1({slots: markRaw({'myEmptySlot': {}, 'default': {__render: slot1.bind(this), __ctx: ctx1}})}, key + \`__1\`, node, this, null);
|
||||
}
|
||||
}"
|
||||
@@ -1676,7 +1676,7 @@ exports[`slots simple slot with slot scope 1`] = `
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
return comp1({slots: markRaw({'slotName': {__render: slot1.bind(this), __ctx: ctx1, __scope: \\"slotScope\\"}})}, key + \`__1\`, node, this, null);
|
||||
}
|
||||
}"
|
||||
@@ -1712,7 +1712,7 @@ exports[`slots slot and (inline) t-call 1`] = `
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
const b3 = comp1({slots: markRaw({'default': {__render: slot1.bind(this), __ctx: ctx1}})}, key + \`__2\`, node, this, null);
|
||||
return block1([], [b3]);
|
||||
}
|
||||
@@ -1762,7 +1762,7 @@ exports[`slots slot and t-call 1`] = `
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
const b3 = comp1({slots: markRaw({'default': {__render: slot1.bind(this), __ctx: ctx1}})}, key + \`__2\`, node, this, null);
|
||||
return block1([], [b3]);
|
||||
}
|
||||
@@ -1997,7 +1997,7 @@ exports[`slots slot content is bound to caller (variation) 1`] = `
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
return comp1({slots: markRaw({'default': {__render: slot1.bind(this), __ctx: ctx1}})}, key + \`__1\`, node, this, null);
|
||||
}
|
||||
}"
|
||||
@@ -2224,7 +2224,7 @@ exports[`slots slot preserves properly parented relationship, even through t-cal
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
const b3 = comp1({slots: markRaw({'default': {__render: slot1.bind(this), __ctx: ctx1}})}, key + \`__2\`, node, this, null);
|
||||
return block1([], [b3]);
|
||||
}
|
||||
@@ -2285,7 +2285,7 @@ exports[`slots slot with slot scope and t-props 1`] = `
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
return comp1({slots: markRaw({'slotName': {__render: slot1.bind(this), __ctx: ctx1, __scope: \\"info\\"}})}, key + \`__1\`, node, this, null);
|
||||
}
|
||||
}"
|
||||
@@ -2387,7 +2387,7 @@ exports[`slots slots are rendered with proper context 1`] = `
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let txt1 = ctx['state'].val;
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
const b3 = comp1({slots: markRaw({'footer': {__render: slot1.bind(this), __ctx: ctx1}})}, key + \`__1\`, node, this, null);
|
||||
return block1([txt1], [b3]);
|
||||
}
|
||||
@@ -2431,7 +2431,7 @@ exports[`slots slots are rendered with proper context, part 2 1`] = `
|
||||
for (let i1 = 0; i1 < l_block2; i1++) {
|
||||
ctx[\`user\`] = v_block2[i1];
|
||||
const key1 = ctx['user'].id;
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
const b7 = comp1({to: '/user/'+ctx['user'].id,slots: markRaw({'default': {__render: slot1.bind(this), __ctx: ctx1}})}, key + \`__1__\${key1}\`, node, this, null);
|
||||
c_block2[i1] = withKey(block3([], [b7]), key1);
|
||||
}
|
||||
@@ -2480,7 +2480,7 @@ exports[`slots slots are rendered with proper context, part 3 1`] = `
|
||||
ctx[\`user\`] = v_block2[i1];
|
||||
const key1 = ctx['user'].id;
|
||||
setContextValue(ctx, \\"userdescr\\", 'User '+ctx['user'].name);
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
const b5 = comp1({to: '/user/'+ctx['user'].id,slots: markRaw({'default': {__render: slot1.bind(this), __ctx: ctx1}})}, key + \`__1__\${key1}\`, node, this, null);
|
||||
c_block2[i1] = withKey(block3([], [b5]), key1);
|
||||
}
|
||||
@@ -2523,7 +2523,7 @@ exports[`slots slots are rendered with proper context, part 4 1`] = `
|
||||
ctx = Object.create(ctx);
|
||||
ctx[isBoundary] = 1
|
||||
setContextValue(ctx, \\"userdescr\\", 'User '+ctx['state'].user.name);
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
const b3 = comp1({to: '/user/'+ctx['state'].user.id,slots: markRaw({'default': {__render: slot1.bind(this), __ctx: ctx1}})}, key + \`__1\`, node, this, null);
|
||||
return block1([], [b3]);
|
||||
}
|
||||
@@ -2565,7 +2565,7 @@ exports[`slots slots in slots, with vars 1`] = `
|
||||
ctx = Object.create(ctx);
|
||||
ctx[isBoundary] = 1
|
||||
setContextValue(ctx, \\"test\\", ctx['state'].name);
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
const b3 = comp1({slots: markRaw({'default': {__render: slot1.bind(this), __ctx: ctx1}})}, key + \`__1\`, node, this, null);
|
||||
return block1([], [b3]);
|
||||
}
|
||||
@@ -2627,7 +2627,7 @@ exports[`slots slots in t-foreach and re-rendering 1`] = `
|
||||
ctx[\`n\`] = v_block2[i1];
|
||||
ctx[\`n_index\`] = i1;
|
||||
const key1 = ctx['n_index'];
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
c_block2[i1] = withKey(comp1({slots: markRaw({'default': {__render: slot1.bind(this), __ctx: ctx1}})}, key + \`__1__\${key1}\`, node, this, null), key1);
|
||||
}
|
||||
const b2 = list(c_block2);
|
||||
@@ -2682,7 +2682,7 @@ exports[`slots slots in t-foreach in t-foreach 1`] = `
|
||||
for (let i2 = 0; i2 < l_block6; i2++) {
|
||||
ctx[\`node2\`] = v_block6[i2];
|
||||
const key2 = ctx['node2'].key;
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
c_block6[i2] = withKey(comp1({slots: markRaw({'default': {__render: slot1.bind(this), __ctx: ctx1}})}, key + \`__1__\${key1}__\${key2}\`, node, this, null), key2);
|
||||
}
|
||||
ctx = ctx.__proto__;
|
||||
@@ -2734,7 +2734,7 @@ exports[`slots slots in t-foreach with t-set and re-rendering 1`] = `
|
||||
ctx[\`n_index\`] = i1;
|
||||
const key1 = ctx['n_index'];
|
||||
setContextValue(ctx, \\"dummy\\", ctx['n_index']);
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
c_block2[i1] = withKey(comp1({slots: markRaw({'default': {__render: slot1.bind(this), __ctx: ctx1}})}, key + \`__1__\${key1}\`, node, this, null), key1);
|
||||
}
|
||||
const b2 = list(c_block2);
|
||||
@@ -2774,7 +2774,7 @@ exports[`slots t-debug on a t-set-slot (defining a slot) 1`] = `
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
const b3 = comp1({slots: markRaw({'content': {__render: slot1.bind(this), __ctx: ctx1}})}, key + \`__1\`, node, this, null);
|
||||
return block1([], [b3]);
|
||||
}
|
||||
@@ -2813,7 +2813,7 @@ exports[`slots t-set t-value in a slot 1`] = `
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
const b3 = comp1({slots: markRaw({'default': {__render: slot1.bind(this), __ctx: ctx1}})}, key + \`__1\`, node, this, null);
|
||||
return block1([], [b3]);
|
||||
}
|
||||
@@ -2847,7 +2847,7 @@ exports[`slots t-set-slot=default has priority over rest of the content 1`] = `
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
return comp1({slots: markRaw({'default': {__render: slot1.bind(this), __ctx: ctx1}})}, key + \`__1\`, node, this, null);
|
||||
}
|
||||
}"
|
||||
@@ -2905,7 +2905,7 @@ exports[`slots t-slot in recursive templates 1`] = `
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
return comp1({slots: markRaw({'default': {__render: slot1.bind(this), __ctx: ctx1}})}, key + \`__2\`, node, this, null);
|
||||
}
|
||||
}"
|
||||
@@ -3083,7 +3083,7 @@ exports[`slots t-slot within dynamic t-call 1`] = `
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const ctx1 = capture(ctx, this);
|
||||
const ctx1 = capture(ctx);
|
||||
const b3 = comp1({slots: markRaw({'default': {__render: slot1.bind(this), __ctx: ctx1}})}, key + \`__2\`, node, this, null);
|
||||
return block1([], [b3]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user