Skip to content

perf: speed up cell rendering #4724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
17 changes: 9 additions & 8 deletions src/js/core/cell/Cell.js
Original file line number Diff line number Diff line change
@@ -98,36 +98,37 @@ export default class Cell extends CoreFeature{

//generate cell contents
_generateContents(){
var val;

val = this.chain("cell-format", this, null, () => {
return this.element.innerHTML = this.value;
const val = this.chain("cell-format", this, null, () => {
return this.value;
});

switch(typeof val){
case "object":
if(val instanceof Node){

//clear previous cell contents
while(this.element.firstChild) this.element.removeChild(this.element.firstChild);

this._clearCellContent();
this.element.appendChild(val);
}else{
this.element.innerHTML = "";
this._clearCellContent();

if(val != null){
console.warn("Format Error - Formatter has returned a type of object, the only valid formatter object return is an instance of Node, the formatter returned:", val);
}
}
break;
case "undefined":
this.element.innerHTML = "";
this._clearCellContent();
break;
default:
this.element.innerHTML = val;
}
}

_clearCellContent(){
while(this.element.firstChild) this.element.removeChild(this.element.firstChild);
}

cellRendered(){
this.dispatch("cell-rendered", this);
}