kontent-ai / kontent-delivery-node-parser

Rich text element parser for node.js & javascript delivery SDK.
MIT License
0 stars 2 forks source link

preserveResolvedObjectTags set to false preserve object tags #3

Open noreiller opened 1 year ago

noreiller commented 1 year ago

Brief bug description

When I use the node example with the option preserveResolvedObjectTags: false, the HTML output still contains the A or OBJECT tags.

If you replace the parentNode instead of adding it to the childNodes, it works better: https://github.com/kontent-ai/kontent-delivery-node-parser/blob/master/lib/parser/implementation/shared.ts#L155

-    element.childNodes = [rootNode];
+    Object.entries(rootNode).forEach(([attributeName, attributeValue]) => {
+        element[attributeName] = attributeValue
+    })

Expected behavior

No duplicated tags.

Test environment

Additional context

Add any other context about the problem here.

Screenshots

Add links to screenshots, if possible.