Skip to content

Commit

Permalink
[FIX] XMLTemplateAnalyzer: Throws on tags without attributes (#322)
Browse files Browse the repository at this point in the history
When processing XML tags with no attributes, getAttributeNS caused an Error like this:
```
TypeError: Cannot convert undefined or null to object
    at Function.values (<anonymous>)
    at getAttributeNS
```
  • Loading branch information
matushorvath authored and matz3 committed Sep 4, 2019
1 parent 2f9a816 commit b7f3795
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/lbt/analyzer/XMLTemplateAnalyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function getAttribute(node, attr) {
return (node.$ && node.$[attr] && node.$[attr].value) || null;
}
function getAttributeNS(node, attrNS) {
const attr = Object.values(node.$).find((n) => {
const attr = Object.values(node.$ || []).find((n) => {
return n.uri === attrNS.uri && n.local === attrNS.local;
});
return (attr && attr.value) || null;
Expand Down
1 change: 1 addition & 0 deletions test/lib/lbt/analyzer/XMLTemplateAnalyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ test("integration: Analysis of an xml view", async (t) => {
<m:Button text="Button 1" id="button1" />
<m:Button text="Button 2" id="button2" />
<m:Button text="Button 3" id="button3" />
<m:Button />
</l:HorizontalLayout>
</mvc:View>`;
const mockPool = {async findResource(name) {
Expand Down

0 comments on commit b7f3795

Please sign in to comment.