Open svobik7 opened 4 months ago
Describe the bug There is a namespace misalignment when creating child element with .ele and when importing fragment child using .import.
.ele
.import
To Reproduce ⚙️ Try to run following functions and compare their outputs.
function workingExample() { const doc = create({ version: '1.0' }); const root = doc.ele('ns1', 'Root'); // creates Child element with proper namespace set to "ns2" root.ele('ns2', 'Child').txt('text'); return doc.end({ prettyPrint: true }) }
✅ Output of workingExample function that is OK:
workingExample
<?xml version="1.0"?> <Root xmlns="ns1"> <Child xmlns="ns2">text</Child> </Root>
function notWorkingExample() { const doc = create({ version: '1.0' }); const root = doc.ele('ns1', 'Root'); // inserts Child element (fragment) but namespace 'ns2' is omitted const child = fragment().ele('ns2', 'Child').txt('text'); root.import(child); return doc.end({ prettyPrint: true }) }
⚠️ Output of notWorkingExample function that is NOK:
notWorkingExample
<?xml version="1.0"?> <Root xmlns="ns1"> <Child>text</Child> </Root>
Expected behavior Output of notWorkingExample function is equal to output of workingExample = both functions output:
Version:
I've also encountered this issue and can confirm that the PR addresses it for me. Haven't noticed any other issues.
Seeing the same issues coming from 2 and going to 3
Describe the bug There is a namespace misalignment when creating child element with
.ele
and when importing fragment child using.import
.To Reproduce ⚙️ Try to run following functions and compare their outputs.
✅ Output of
workingExample
function that is OK:⚠️ Output of
notWorkingExample
function that is NOK:Expected behavior Output of
notWorkingExample
function is equal to output ofworkingExample
= both functions output:Version: