Skip to content

Commit c82b6a6

Browse files
authored
Merge pull request #431 from Zhong-z/main
Prevent duplicate class assignment for table attributes in DataTable
2 parents 8f56ede + a6fe24f commit c82b6a6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/datatable.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,9 @@ export class DataTable {
452452

453453
]
454454
}
455-
tableVirtualDOM.attributes.class = joinWithSpaces(tableVirtualDOM.attributes.class, this.options.classes.table)
455+
if (!tableVirtualDOM.attributes.class.includes(this.options.classes.table)) {
456+
tableVirtualDOM.attributes.class = joinWithSpaces(tableVirtualDOM.attributes.class, this.options.classes.table)
457+
}
456458
if (this.options.tableRender) {
457459
const renderedTableVirtualDOM : (elementNodeType | void) = this.options.tableRender(this.data, tableVirtualDOM, "header")
458460
if (renderedTableVirtualDOM) {
@@ -1107,7 +1109,9 @@ export class DataTable {
11071109
this._tableFooters.forEach(footer => newVirtualDOM.childNodes.push(footer))
11081110
this._tableCaptions.forEach(caption => newVirtualDOM.childNodes.push(caption))
11091111

1110-
newVirtualDOM.attributes.class = joinWithSpaces(newVirtualDOM.attributes.class, this.options.classes.table)
1112+
if (!newVirtualDOM.attributes.class.includes(this.options.classes.table)) {
1113+
newVirtualDOM.attributes.class = joinWithSpaces(newVirtualDOM.attributes.class, this.options.classes.table)
1114+
}
11111115

11121116
if (this.options.tableRender) {
11131117
const renderedTableVirtualDOM : (elementNodeType | void) = this.options.tableRender(this.data, newVirtualDOM, "message")

0 commit comments

Comments
 (0)