Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/components/ContentNode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,11 @@ function renderNode(createElement, references) {
node.text
));
case BlockType.orderedList:
return createElement('ol', {}, (
return createElement('ol', {
attrs: {
start: node.start,
},
}, (
renderListItems(node.items)
));
case BlockType.paragraph:
Expand Down
45 changes: 45 additions & 0 deletions tests/unit/components/ContentNode.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,51 @@ describe('ContentNode', () => {

const list = wrapper.find('.content ol');
expect(list.exists()).toBe(true);
expect(list.attributes('start')).toBeUndefined();

const items = list.findAll('li');
expect(items.length).toBe(2);
expect(items.at(0).find('p').text()).toBe('foo');
expect(items.at(1).find('p').text()).toBe('bar');
});

it('renders an <ol> with <li> items and a custom start index', () => {
const wrapper = mountWithItem({
type: 'orderedList',
start: 2,
items: [
{
content: [
{
type: 'paragraph',
inlineContent: [
{
type: 'text',
text: 'foo',
},
],
},
],
},
{
content: [
{
type: 'paragraph',
inlineContent: [
{
type: 'text',
text: 'bar',
},
],
},
],
},
],
});

const list = wrapper.find('.content ol');
expect(list.exists()).toBe(true);
expect(list.attributes('start')).toBe('2');

const items = list.findAll('li');
expect(items.length).toBe(2);
Expand Down