Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/XmlScope.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ describe('XmlScope', () => {
<function id="func3" />
<function name="" />
<function name />
<field id="field1" type="string" onChange="func4" />
</interface>
<script uri="child.brs"/>
</component>
Expand All @@ -127,6 +128,9 @@ describe('XmlScope', () => {
range: Range.create(7, 9, 7, 17)
}, { // syntax error expecting '=' but found '/>'
code: DiagnosticMessages.xmlGenericParseError('').code
}, { // onChange function
...DiagnosticMessages.xmlFunctionNotFound('func4'),
range: Range.create(8, 51, 8, 56)
}]);
});

Expand Down
11 changes: 10 additions & 1 deletion src/XmlScope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class XmlScope extends Scope {
}
//validate fields
for (const field of api.fields) {
const { id, type } = field;
const { id, type, onChange } = field;
if (!id) {
this.diagnosticMissingAttribute(field, 'id');
}
Expand All @@ -86,6 +86,15 @@ export class XmlScope extends Scope {
file: this.xmlFile
});
}
if (onChange) {
if (!callableContainerMap.has(onChange.toLowerCase())) {
this.diagnostics.push({
...DiagnosticMessages.xmlFunctionNotFound(onChange),
range: field.getAttribute('onchange').value.range,
file: this.xmlFile
});
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/parser/SGTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class SGTag {
}

getAttributeValue(name: string): string | undefined {
return this.getAttribute(name)?.value?.text;
return this.getAttribute(name.toLowerCase())?.value?.text;
}

setAttribute(name: string, value: string) {
Expand Down