Skip to content

Instantly share code, notes, and snippets.

@jsmanifest
Created March 28, 2020 15:48
Show Gist options
  • Save jsmanifest/a104ebf2b9af27895728c81b02fc9b48 to your computer and use it in GitHub Desktop.
Save jsmanifest/a104ebf2b9af27895728c81b02fc9b48 to your computer and use it in GitHub Desktop.
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