Skip to content

Invalidate#112

Merged
texodus merged 2 commits intomasterfrom
invalidate
Feb 5, 2021
Merged

Invalidate#112
texodus merged 2 commits intomasterfrom
invalidate

Conversation

@texodus
Copy link
Copy Markdown
Member

@texodus texodus commented Feb 5, 2021

From the new documentation for this feature:

To prevent DOM renders, <regular-table> conserves DOM calls like offsetWidth to an internal cache. When a <td> or <th>'s width is modified within a callback to .addStyleListener(), you must indicate to <regular-table> that its dimensions have changed in order to invalidate this cache, or you may not end up with enough rendered columns to fill the screen!

A call to invalidate() that does not need new columns only imparts a small runtime overhead to re-calculate virtual width per async draw iteration, but should be used conservatively if possible. Calling invalidate() outside of a callback to .addStyleListener() will throw an Error.

table.addStyleListener(() => {
    for (const th of table.querySelectorAll("tbody th")) {
        th.style.maxWidth = "20px";
    }
    table.invalidate();
});

@JHawk
Copy link
Copy Markdown
Contributor

JHawk commented Feb 5, 2021

Simple and effective - looks great!

@texodus texodus merged commit 28f7cd7 into master Feb 5, 2021
@texodus texodus deleted the invalidate branch February 5, 2021 21:03
@texodus texodus added the enhancement Feature requests or improvements label Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Feature requests or improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants