Skip to content

Use resolveProperty callback for lazy computed style resolution#4085

Closed
domenic wants to merge 1 commit intomainfrom
resolve-property-callback
Closed

Use resolveProperty callback for lazy computed style resolution#4085
domenic wants to merge 1 commit intomainfrom
resolve-property-callback

Conversation

@domenic
Copy link
Copy Markdown
Member

@domenic domenic commented Feb 25, 2026

Lazy computed style resolution via a resolveProperty callback, replacing the hardcoded property table with metadata derived from the generated property definitions.

@domenic domenic force-pushed the resolve-property-callback branch from 3886d9f to a9052d8 Compare March 14, 2026 10:21
@domenic domenic marked this pull request as ready for review March 19, 2026 06:05
@domenic domenic force-pushed the resolve-property-callback branch from 0db0c9d to 511e5bf Compare March 19, 2026 06:10
@domenic domenic marked this pull request as draft March 19, 2026 06:14
@domenic domenic force-pushed the resolve-property-callback branch 2 times, most recently from 48a0cb9 to 9fdae31 Compare March 19, 2026 06:25
@domenic domenic marked this pull request as ready for review March 19, 2026 06:26
@domenic domenic force-pushed the resolve-property-callback branch 4 times, most recently from e674b6b to 2dd0321 Compare March 19, 2026 09:10
@domenic
Copy link
Copy Markdown
Member Author

domenic commented Mar 19, 2026

Finally got this working. @asamuzaK do you want to take a look? I'd like to merge this and #4117 and do a patch release soon.

@asamuzaK
Copy link
Copy Markdown
Contributor

I'm thinking of going in the direction of #4119.

@domenic
Copy link
Copy Markdown
Member Author

domenic commented Mar 20, 2026

Great! Maybe I should do a release without either first, to get the minor bug fixes released.

Regarding which approach is better, I am happy to let you take the lead. Maybe we can combine them. I think we can judge which is based based on:

  • Amount of new passing tests
  • Speedup per benchmarks (including new benchmarks added in this PR; maybe I should merge those benchmarks separately from this PR)
  • Reduction in code complexity. (Right now this PR has an advantage because it completely removes propertiesWithResolvedValueImplemented. But I see Resolve computed style value #4119 only uses that to figure out colors, so, maybe borrowing some work from this PR, like the prepare script, can help close the gap.)

@domenic domenic force-pushed the resolve-property-callback branch 2 times, most recently from 6a8f97d to 98a3ae9 Compare March 23, 2026 11:47
domenic pushed a commit that referenced this pull request Mar 31, 2026
Replace the hardcoded property table in computed-style.js with a dynamic getPropertyMetadata() function that reads from the generated css-property-definitions.js. Instead of eagerly pre-computing all property values, pass a resolveProperty callback to CSSStyleDeclaration that lazily resolves values on-demand when getPropertyValue is called.

Benchmarks show 6-22x improvement on getComputedStyle operations, with the biggest gains on the warm-cache path (13-14x) since properties are now resolved only when accessed rather than all up front.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@domenic domenic force-pushed the resolve-property-callback branch from 98a3ae9 to 45fff87 Compare March 31, 2026 03:56
@domenic domenic closed this in 4097d66 Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants