Skip to content

Commit

Permalink
fix: replace a few innerHTML by more secure alternatives (#885)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding authored Oct 27, 2023
1 parent a08b0f8 commit 53ab293
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/controls/slick.columnmenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class SlickColumnMenu {
const spanCloseElm = document.createElement('span');
spanCloseElm.className = 'close';
spanCloseElm.ariaHidden = 'true';
spanCloseElm.innerHTML = '×';
spanCloseElm.textContent = '×';
buttonElm.appendChild(spanCloseElm);
this._menuElm.appendChild(buttonElm);

Expand Down
2 changes: 1 addition & 1 deletion src/controls/slick.columnpicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class SlickColumnPicker {
const spanCloseElm = document.createElement('span');
spanCloseElm.className = 'close';
spanCloseElm.ariaHidden = 'true';
spanCloseElm.innerHTML = '×';
spanCloseElm.textContent = '×';
buttonElm.appendChild(spanCloseElm);
this._menuElm.appendChild(buttonElm);

Expand Down
2 changes: 1 addition & 1 deletion src/controls/slick.gridmenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ export class SlickGridMenu {
const spanCloseElm = document.createElement('span');
spanCloseElm.className = 'close';
spanCloseElm.ariaHidden = 'true';
spanCloseElm.innerHTML = '×';
spanCloseElm.textContent = '×';
closeButtonElm.appendChild(spanCloseElm);
menuElm.appendChild(closeButtonElm);
}
Expand Down
2 changes: 1 addition & 1 deletion src/controls/slick.pager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class SlickGridPager {
destroy() {
this.setPageSize(0);
this._bindingEventService.unbindAll();
this._container.innerHTML = '';
Utils.emptyElement(this._container);
}

protected getNavState() {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/slick.contextmenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export class SlickContextMenu implements SlickPlugin {
const spanCloseElm = document.createElement('span');
spanCloseElm.className = 'close';
spanCloseElm.ariaHidden = 'true';
spanCloseElm.innerHTML = '×';
spanCloseElm.textContent = '×';
closeButtonElm.appendChild(spanCloseElm);
}

Expand Down
6 changes: 3 additions & 3 deletions src/slick.grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2971,7 +2971,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
}
}

cellEl.innerHTML = maxText;
cellEl.textContent = maxText;
len = cellEl.offsetWidth;

rowEl.remove();
Expand Down Expand Up @@ -4085,7 +4085,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
formatterResult = this.getFormatter(row, m)(row, columnIdx, this.getDataItemValueForColumn(d, m), m, d, this as unknown as SlickGridModel);
this.applyFormatResultToCellNode(formatterResult, node as HTMLDivElement);
} else {
node.innerHTML = '';
Utils.emptyElement(node);
}
}

Expand Down Expand Up @@ -5766,7 +5766,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e

// don't clear the cell if a custom editor is passed through
if (!editor && !useEditor.suppressClearOnEdit) {
this.activeCellNode.innerHTML = '';
Utils.emptyElement(this.activeCellNode);
}

let metadata = (this.data as CustomDataView<TData>)?.getItemMetadata?.(this.activeRow);
Expand Down

0 comments on commit 53ab293

Please sign in to comment.