|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
559 bytes
|
| Line | |
|---|
| 1 | 'use strict'
|
|---|
| 2 |
|
|---|
| 3 | const walk = ( node, parent, cb ) => {
|
|---|
| 4 | cb( node, parent )
|
|---|
| 5 |
|
|---|
| 6 | if( Array.isArray( node.children ) )
|
|---|
| 7 | node.children.forEach( child => walk( child, node, cb ) )
|
|---|
| 8 | }
|
|---|
| 9 |
|
|---|
| 10 | const data = {
|
|---|
| 11 | name: 'div',
|
|---|
| 12 | attribs: {
|
|---|
| 13 | id: 'container',
|
|---|
| 14 | class: 'message'
|
|---|
| 15 | },
|
|---|
| 16 | children: [
|
|---|
| 17 | {
|
|---|
| 18 | name: 'strong',
|
|---|
| 19 | attribs: {
|
|---|
| 20 | class: 'message'
|
|---|
| 21 | },
|
|---|
| 22 | children: [
|
|---|
| 23 | { text: 'Hello' }
|
|---|
| 24 | ]
|
|---|
| 25 | },
|
|---|
| 26 | { text: ', World!' }
|
|---|
| 27 | ]
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | walk( data, null, ( node, parent ) => {
|
|---|
| 31 | if( parent ) node.parent = parent
|
|---|
| 32 | })
|
|---|
| 33 |
|
|---|
| 34 | module.exports = [ data ]
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.