Merge pull request #141 from satkowski/fix-missing-number-handling

Fix: fixed the missing handling of numbers for renderer
This commit is contained in:
Kacper Kula 2025-04-10 10:01:30 +01:00 committed by GitHub
commit 7ed7934993
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 2 deletions

View file

@ -11,7 +11,7 @@ export interface Result {
onRunCallback?: OnRunCallback
}
export type CellParserResult = Result | string | HTMLElement
export type CellParserResult = Result | string | HTMLElement | number
export class ModernCellParser {
@ -84,6 +84,8 @@ export class ModernCellParser {
const res = this.prepare(content)
if (typeof res === 'string' || !res) {
return res
} else if (typeof res === 'number') {
return res.toString()
} else if (res instanceof HTMLElement) {
return res
} else {

View file

@ -14,7 +14,7 @@ class RenderContext {
render(context: string) {
const res = this.cellParser.prepare(context)
if (typeof res === 'string') {
if (typeof res === 'string' || typeof res === 'number') {
return res
}
if (res instanceof HTMLElement) {

View file

@ -26,6 +26,8 @@ export class ParseResults {
}
} else if (typeof data === 'string') {
res[col] = data
} else if (typeof data === 'number') {
res[col] = data.toString()
} else if (!data) {
res[col] = ''
} else {