Skip to content

Commit

Permalink
don't copy aliases to contexted yield implicit with section - fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
evs-chris committed Sep 16, 2019
1 parent b263b2d commit 79fe264
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/view/items/Partial.js
Expand Up @@ -242,9 +242,10 @@ function createFragment(self, partial) {

function contextifyTemplate(self) {
if (self.template.c) {
self.partial = [{ t: SECTION, n: SECTION_WITH, f: self.partial, z: self.template.z }];
self.partial = [{ t: SECTION, n: SECTION_WITH, f: self.partial }];
assign(self.partial[0], self.template.c);
if (self.yielder) self.partial[0].y = self;
else self.partial[0].z = self.template.z;
}
}

Expand Down
26 changes: 26 additions & 0 deletions tests/browser/partials.js
Expand Up @@ -1298,6 +1298,32 @@ export default function() {
t.htmlEqual(fixture.innerHTML, '99 42');
});

test(`yield with context and aliases #3316`, t => {
const cmp = Ractive.extend({
template: `{{yield part with baz, 'str' as lit, foo as param, fn() as fn}}`,
partials: {
part: `{{JSON.stringify(.)}}, {{lit}}, {{param}}, {{fn}}`
},
data() {
return {
fn() {
return 'fn!';
},
foo: 'foo!',
baz: { baz: 42 }
};
}
});

new Ractive({
target: fixture,
components: { cmp },
template: '<cmp />'
});

t.htmlEqual(fixture.innerHTML, '{"baz":42}, str, foo!, fn!');
});

test(`dynamic partials retain context (#3297)`, t => {
const r = new Ractive({
target: fixture,
Expand Down

0 comments on commit 79fe264

Please sign in to comment.