Skip to content

Commit

Permalink
(feat): Parse element nodes in attrs for elements (#912)
Browse files Browse the repository at this point in the history
  • Loading branch information
JayaKrishnaNamburu authored Jul 17, 2024
1 parent 54218e1 commit 0fce54a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/teleport-uidl-resolver/src/resolvers/abilities/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ export const insertLinks = (
linkInParent: boolean = false,
parentNode?: UIDLElementNode
): UIDLElementNode => {
// TODO_NOW
const { abilities, children, elementType, semanticType } = node.content
const { abilities, children, elementType, semanticType, attrs = {} } = node.content
const linkInNode = linkInParent || !!abilities?.link

// TODO: think of a way to reuse the traversal that modifies the tree
node.content.children = children?.map((child) => {
if (child.type === 'element') {
return insertLinks(child, options, linkInNode, node)
Expand Down Expand Up @@ -106,6 +104,14 @@ export const insertLinks = (
return child
})

for (const attrKey of Object.keys(attrs)) {
const attr = attrs[attrKey]

if (attr.type === 'element') {
node.content.attrs[attrKey] = insertLinks(attr as UIDLElementNode, options, false, node)
}
}

if (abilities?.link) {
if (linkInParent) {
console.warn('parent node has a link capability, nesting links is illegal')
Expand Down

0 comments on commit 0fce54a

Please sign in to comment.