(buff, doc)
| 10 | } |
| 11 | |
| 12 | function stringify(buff, doc) { |
| 13 | switch (doc.type) { |
| 14 | case 'text': |
| 15 | return buff + doc.content |
| 16 | case 'tag': |
| 17 | buff += |
| 18 | '<' + |
| 19 | doc.name + |
| 20 | (doc.attrs ? attrString(doc.attrs) : '') + |
| 21 | (doc.voidElement ? '/>' : '>') |
| 22 | if (doc.voidElement) { |
| 23 | return buff |
| 24 | } |
| 25 | return buff + doc.children.reduce(stringify, '') + '</' + doc.name + '>' |
| 26 | case 'comment': |
| 27 | buff += '<!--' + doc.comment + '-->' |
| 28 | return buff |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | export default function (doc) { |
| 33 | return doc.reduce(function (token, rootEl) { |
no test coverage detected
searching dependent graphs…