SCEditor icon indicating copy to clipboard operation
SCEditor copied to clipboard

Implement style cache

Open live627 opened this issue 3 months ago • 0 comments

Motivation

Nodes are frequently created, updated, and destroyed, but would always use the same styles. Repeated calls to getComputedStyle() for the same or similar elements were causing noticeable performance degradation because the browser was recalculating the same or similar styles.

Summary of Changes

  • Signature-based caching

    • Computed styles are cached using a signature derived from an element’s tagName, id, class, and style attributes.
    • Elements with the same signature reuse the cached style snapshot.
  • API

    • dom.cachedCss(node, "prop") → returns a single computed property.
    • dom.cachedCss(node, ["prop"]) → returns one or more computed properties as object.
    • dom.cachedCss(node, "prop", "val") → sets inline style

live627 avatar Sep 26 '25 03:09 live627