fix hex parsing

This commit is contained in:
Rachel Powers
2024-04-17 14:44:22 -07:00
parent b60cc44580
commit 8ec48c508a
2 changed files with 11 additions and 7 deletions

View File

@@ -181,9 +181,11 @@ export function parseNumber(s: string): number {
if (/^\$[0-9A-Fa-f]+$/.test(s)) {
return parseInt(s.slice(1), 16)
}
const hex = parseHex(s);
if (!isNaN(hex)) {
return hex;
if (/[a-fA-F]/.test(s)) {
const hex = parseHex(s);
if (!isNaN(hex)) {
return hex;
}
}
return parseFloat(s);
}
@@ -204,9 +206,11 @@ export function parseIntWithHexOrBinary(s: string): number {
if (/^\$[0-9A-Fa-f]+$/.test(s)) {
return parseInt(s.slice(1), 16)
}
const hex = parseHex(s);
if (!isNaN(hex)) {
return hex;
if (/[a-fA-F]/.test(s)) {
const hex = parseHex(s);
if (!isNaN(hex)) {
return hex;
}
}
return parseInt(s);
}

View File

@@ -460,7 +460,7 @@ export class VMDeviceList extends BaseElement {
protected render(): HTMLTemplateResult {
const deviceCards: HTMLTemplateResult[] = this.filteredDeviceIds.map(
(id, _index, _ids) =>
html`< vm - device - card.deviceID=${ id } class="device-list-card" > </vm-device-card>`,
html`<vm-device-card .deviceID=${id} class="device-list-card" > </vm-device-card>`,
);
const result = html`
<div class="header">