Skip to content

Commit

Permalink
Added direct object support
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber committed May 4, 2019
1 parent 61c3610 commit f74757f
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Subslot.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default {
type: Boolean,
},
element: {
type: [Array, String],
type: [Object, Array, String],
},
offset: {
type: [String, Number],
Expand Down
25 changes: 25 additions & 0 deletions test/__snapshots__/test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,31 @@ exports[`Subslot Should support array slicing 1`] = `
</div>
`;

exports[`Subslot Should support element as a direct reference 1`] = `
<div
class="card"
>
<div
class="card-header"
>
<div>
Header
</div>
</div>
<div
class="card-content"
>
Content
</div>
</div>
`;

exports[`Subslot Should support filter attributes 1`] = `
<div
class="card"
Expand Down
45 changes: 45 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,51 @@ describe('Subslot', () => {
expect(wrapper.element).toMatchSnapshot();
});

test('Should support element as a direct reference', () => {
const Card = {
template: `
<div class="card">
<div class="card-header">
<subslot :element="CardHeader" limit="1" />
</div>
<div class="card-content">
<subslot not :element="CardHeader" />
</div>
</div>
`,

components: {
Subslot,
},

data() {
return {
CardHeader,
};
},
};

const usage = {
template: `
<card>
<card-header>
Header
</card-header>
Content
</card>
`,
components: {
Card,
CardHeader,
},
};

const wrapper = mount(usage);
expect(wrapper.element).toMatchSnapshot();
});

test('Should support named subslots', () => {
const Card = {
template: `
Expand Down

0 comments on commit f74757f

Please sign in to comment.