Created
March 28, 2020 15:48
-
-
Save jsmanifest/a104ebf2b9af27895728c81b02fc9b48 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function transformAll({ type = '', style = {}, children = [] }) { | |
const result = { type, style: transformStyleObject(style), children } | |
if (Array.isArray(result.children)) { | |
for (let index = 0; index < result.children.length; index++) { | |
const child = result.children[index] | |
child.style = transformStyleObject(child.style) | |
if (Array.isArray(child.children)) { | |
for ( | |
let childIndex = 0; | |
childIndex < child.children.length; | |
childIndex++ | |
) { | |
const childsChildren = child.children[childIndex] | |
childsChildren.style = transformStyleObject(childsChildren.style) | |
if (Array.isArray(childsChildren.children)) { | |
for ( | |
let childsChildsChildrenIndex = 0; | |
childsChildsChildrenIndex < childsChildren.children.length; | |
childsChildsChildrenIndex++ | |
) { | |
const childsChildsChild = | |
childsChildren.children[childsChildsChildrenIndex] | |
// ...etc | |
} | |
} | |
} | |
} | |
} | |
} | |
return result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment