Skip to content

Commit cee123a

Browse files
Removing logic that was replacing child nodes by attribute nodes. Totally weird.
1 parent b742613 commit cee123a

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

src/xslt/xslt.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,10 @@ export class Xslt {
577577
return;
578578
}
579579

580+
// TODO: Why do we need this sort, really?
581+
// I have no idea why this logic is here (it was implemented
582+
// before Design Liquido taking over), so if it is proven not useful,
583+
// this entire logic must be removed.
580584
const sortContext = context.clone(nodes);
581585
this.xsltSort(sortContext, template);
582586

@@ -585,8 +589,10 @@ export class Xslt {
585589
throw new Error('Nodes with no parents defined.');
586590
}
587591

588-
const parent = nodesWithParent[0].parentNode;
589-
parent.childNodes = sortContext.nodeList;
592+
// TODO: Removed for now because sortContext can select attributes,
593+
// and attributes are separated from child nodes.
594+
/* const parent = nodesWithParent[0].parentNode;
595+
parent.childNodes = sortContext.nodeList; */
590596

591597
for (let i = 0; i < sortContext.contextSize(); ++i) {
592598
this.xsltChildNodes(sortContext.clone(sortContext.nodeList, undefined, i), template, output);

tests/lmht/lmht.test.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,4 +1612,30 @@ describe('LMHT', () => {
16121612

16131613
assert.ok(outXmlString);
16141614
});
1615+
1616+
it('Form Fieldset', () => {
1617+
const xmlString = `<lmht>
1618+
<cabeça><título>Teste</título></cabeça>
1619+
<corpo>
1620+
<titulo1>Detalhes de Artigo</titulo1>
1621+
<formulário método="POST" ação="">
1622+
<campos>
1623+
<etiqueta para="id">id</etiqueta>
1624+
<campo tipo="texto" id="{{id}}"></campo>
1625+
<etiqueta para="titulo">titulo</etiqueta>
1626+
<campo tipo="texto" id="{{titulo}}"></campo>
1627+
<etiqueta para="conteudo">conteudo</etiqueta>
1628+
<campo tipo="texto" id="{{conteudo}}"></campo>
1629+
</campos>
1630+
</formulário>
1631+
</corpo>
1632+
</lmht>`;
1633+
const xsltClass = new Xslt({ selfClosingTags: false });
1634+
const xmlParser = new XmlParser();
1635+
const xml = xmlParser.xmlParse(xmlString);
1636+
const xslt = xmlParser.xmlParse(xsltString);
1637+
const outXmlString = xsltClass.xsltProcess(xml, xslt);
1638+
1639+
assert.ok(outXmlString);
1640+
})
16151641
});

0 commit comments

Comments
 (0)