Skip to content

Preserve classname#139

Merged
texodus merged 2 commits intomasterfrom
preserve-classname
Apr 26, 2021
Merged

Preserve classname#139
texodus merged 2 commits intomasterfrom
preserve-classname

Conversation

@texodus
Copy link
Copy Markdown
Member

@texodus texodus commented Apr 25, 2021

Previously, while subsequent calls to draw() would re-use pre-existing DOM elements such as <th> when appropriate, they would pro-actively clear className before applying the default classes and calling style handlers. This PR removes this behavior, which suppresses some re-renders at the expense of requiring styleListener() implementations to both set and reset any classes they wish to modify (where currently they only need implement set, since draw() would clear the className itself). regular-table's examples all already had this behavior, but this is nonetheless a breaking change.

The old behavior may be trivially implement in a styleListener by resetting className:

table.addStyleListener(() => {
    for (const td of table.querySelectorAll("td, th"}) {
        td.className = "";
        // ...
    }
});

@texodus texodus marked this pull request as ready for review April 26, 2021 03:57
@texodus texodus merged commit 0edc395 into master Apr 26, 2021
@texodus texodus deleted the preserve-classname branch April 26, 2021 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant