Skip to content

Commit f5bce67

Browse files
use ordered list start index when rendering (#30)
1 parent cc1b9bf commit f5bce67

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

src/components/ContentNode.vue

+5-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,11 @@ function renderNode(createElement, references) {
236236
node.text
237237
));
238238
case BlockType.orderedList:
239-
return createElement('ol', {}, (
239+
return createElement('ol', {
240+
attrs: {
241+
start: node.start,
242+
},
243+
}, (
240244
renderListItems(node.items)
241245
));
242246
case BlockType.paragraph:

tests/unit/components/ContentNode.spec.js

+45
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,51 @@ describe('ContentNode', () => {
205205

206206
const list = wrapper.find('.content ol');
207207
expect(list.exists()).toBe(true);
208+
expect(list.attributes('start')).toBeUndefined();
209+
210+
const items = list.findAll('li');
211+
expect(items.length).toBe(2);
212+
expect(items.at(0).find('p').text()).toBe('foo');
213+
expect(items.at(1).find('p').text()).toBe('bar');
214+
});
215+
216+
it('renders an <ol> with <li> items and a custom start index', () => {
217+
const wrapper = mountWithItem({
218+
type: 'orderedList',
219+
start: 2,
220+
items: [
221+
{
222+
content: [
223+
{
224+
type: 'paragraph',
225+
inlineContent: [
226+
{
227+
type: 'text',
228+
text: 'foo',
229+
},
230+
],
231+
},
232+
],
233+
},
234+
{
235+
content: [
236+
{
237+
type: 'paragraph',
238+
inlineContent: [
239+
{
240+
type: 'text',
241+
text: 'bar',
242+
},
243+
],
244+
},
245+
],
246+
},
247+
],
248+
});
249+
250+
const list = wrapper.find('.content ol');
251+
expect(list.exists()).toBe(true);
252+
expect(list.attributes('start')).toBe('2');
208253

209254
const items = list.findAll('li');
210255
expect(items.length).toBe(2);

0 commit comments

Comments
 (0)