Skip to content

Commit

Permalink
fix(ns): keep namespace of imported node childs if defined
Browse files Browse the repository at this point in the history
  • Loading branch information
svobik7 committed Apr 22, 2024
1 parent 216cd30 commit 4d1f29f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/builder/XMLBuilderImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,8 @@ export class XMLBuilderImpl implements XMLBuilder {
clone.prefix ? clone.prefix + ':' + clone.localName : clone.localName
);
const namespace = hostNode.lookupNamespaceURI(prefix)
console.log(prefix, namespace)

new XMLBuilderImpl(clone)._updateNamespace(namespace)
}
};
Expand Down Expand Up @@ -771,7 +773,7 @@ export class XMLBuilderImpl implements XMLBuilder {
for (const childNode of ele.childNodes) {
const newChildNode = childNode.cloneNode(true)
newEle.appendChild(newChildNode)
if (Guard.isElementNode(newChildNode)) {
if (Guard.isElementNode(newChildNode) && !newChildNode._namespace) {
const [newChildNodePrefix] = namespace_extractQName(newChildNode.prefix ? newChildNode.prefix + ':' + newChildNode.localName : newChildNode.localName)
const newChildNodeNS = newEle.lookupNamespaceURI(newChildNodePrefix)
new XMLBuilderImpl(newChildNode)._updateNamespace(newChildNodeNS)
Expand Down

0 comments on commit 4d1f29f

Please sign in to comment.