Skip to content

fix: ensure __AddClass triggers style updates when enableCSSSelector …#2515

Merged
PupilTong merged 1 commit intolynx-family:mainfrom
PupilTong:p/hw/fix-css-og-add-class
Apr 23, 2026
Merged

fix: ensure __AddClass triggers style updates when enableCSSSelector …#2515
PupilTong merged 1 commit intolynx-family:mainfrom
PupilTong:p/hw/fix-css-og-add-class

Conversation

@PupilTong
Copy link
Copy Markdown
Collaborator

@PupilTong PupilTong commented Apr 23, 2026

…is disabled

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Fixed class-to-style application behavior when CSS selector support is disabled, ensuring proper style updates through the expected style population flow.
  • Tests

    • Added end-to-end test coverage for class application scenarios with CSS selector support disabled.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).
  • Changeset added, and when a BREAKING CHANGE occurs, it needs to be clearly marked (or not required).

@PupilTong PupilTong self-assigned this Apr 23, 2026
@PupilTong PupilTong requested a review from Sherry-hue as a code owner April 23, 2026 09:01
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 23, 2026

🦋 Changeset detected

Latest commit: 65f6f3c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@lynx-js/web-core Patch
upgrade-rspeedy Patch
@lynx-js/web-rsbuild-server-middleware Patch
@lynx-js/template-webpack-plugin Patch
@lynx-js/react-rsbuild-plugin Patch
create-rspeedy Patch
@lynx-js/web-worker-rpc Patch
@lynx-js/react-alias-rsbuild-plugin Patch
@lynx-js/rspeedy Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 23, 2026

📝 Walkthrough

Walkthrough

Adds a conditional behavior fix to __AddClass that, when CSS selector support is disabled, delegates style updates to the DOM via update_css_og_style wasm calls. Includes a new E2E test resource and test case that validates class application behavior with disabled CSS selectors, plus corresponding changelog documentation.

Changes

Cohort / File(s) Summary
Changeset Documentation
.changeset/fix-addclass-style.md
Documents a patch-level fix for @lynx-js/web-core addressing __AddClass style update behavior when CSS selector support is disabled.
E2E Test Configuration
packages/web-platform/web-core-e2e/resources/web-core.disable-css-selector.json
Introduces a new JSON resource file that defines test scenario configuration with enableCSSSelector: false and associated style/manifest setup for E2E validation.
E2E Test Implementation
packages/web-platform/web-core-e2e/tests/web-core.test.ts
Adds new test case that validates __AddClass behavior when CSS selectors are disabled, verifying class presence and computed style values match expectations.
Client & Server Element API Updates
packages/web-platform/web-core/ts/client/mainthread/elementAPIs/createElementAPI.ts, packages/web-platform/web-core/ts/server/elementAPIs/createElementAPI.ts
Updates __AddClass implementation with conditional wrapper logic that calls wasmContext.update_css_og_style() when enableCSSSelector is false, ensuring style propagation aligns with __SetClasses behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

platform:Web

Suggested reviewers

  • Sherry-hue

Poem

🐰 When CSS selectors sleep, classes still must flow,
Through wasm paths and DOM so the styles can glow,
Add a class, update style—condition by condition,
Tests affirm our vision, no browser collision! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: fixing __AddClass to trigger style updates when enableCSSSelector is disabled, which is the core behavioral fix across all modified files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

❌ Patch coverage is 72.22222% with 5 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...web-core/ts/server/elementAPIs/createElementAPI.ts 50.00% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/web-platform/web-core-e2e/tests/web-core.test.ts (1)

94-95: Remove debug-only console listeners and RESULT:: log.

page.on('console', ...) / page.on('pageerror', ...) and the console.log('RESULT::', result) look like leftover debugging aids from local iteration. They don't affect assertions but pollute CI output and aren't used by any later assertion (errors aren't collected/asserted). Consider dropping them or, if you want to assert no page errors, push into an array and expect(errors).toEqual([]) like the should not throw error... test at line 1052.

🧹 Suggested cleanup
-    page.on('console', msg => console.log('PAGE LOG:', msg.text()));
-    page.on('pageerror', err => console.log('PAGE ERROR:', err.message));
-
     await goto(page, 'web-core.disable-css-selector.json');
@@
-    console.log('RESULT::', result);
     expect(result.classes).toContain('my-class');

Also applies to: 133-133

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/web-platform/web-core-e2e/tests/web-core.test.ts` around lines 94 -
95, Remove the debug-only console listeners and the RESULT:: log: delete the
page.on('console', msg => ...) and page.on('pageerror', err => ...) handlers and
remove the console.log('RESULT::', result) statement; if you want to assert no
page errors instead, replace the page.on('pageerror', ...) handler with code
that pushes errors into an errors array (e.g., errors.push(err.message)) and add
an assertion like expect(errors).toEqual([]) similar to the existing "should not
throw error..." test, keeping the rest of the test flow unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/web-platform/web-core-e2e/tests/web-core.test.ts`:
- Around line 94-95: Remove the debug-only console listeners and the RESULT::
log: delete the page.on('console', msg => ...) and page.on('pageerror', err =>
...) handlers and remove the console.log('RESULT::', result) statement; if you
want to assert no page errors instead, replace the page.on('pageerror', ...)
handler with code that pushes errors into an errors array (e.g.,
errors.push(err.message)) and add an assertion like expect(errors).toEqual([])
similar to the existing "should not throw error..." test, keeping the rest of
the test flow unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c7d53e40-cc73-4730-a430-0f32717d8a5b

📥 Commits

Reviewing files that changed from the base of the PR and between 13655ac and 65f6f3c.

📒 Files selected for processing (5)
  • .changeset/fix-addclass-style.md
  • packages/web-platform/web-core-e2e/resources/web-core.disable-css-selector.json
  • packages/web-platform/web-core-e2e/tests/web-core.test.ts
  • packages/web-platform/web-core/ts/client/mainthread/elementAPIs/createElementAPI.ts
  • packages/web-platform/web-core/ts/server/elementAPIs/createElementAPI.ts

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 23, 2026

Merging this PR will improve performance by 5.07%

⚡ 1 improved benchmark
✅ 80 untouched benchmarks
⏩ 26 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
transform 1000 view elements 46.8 ms 44.5 ms +5.07%

Comparing PupilTong:p/hw/fix-css-og-add-class (65f6f3c) with main (13655ac)

Open in CodSpeed

Footnotes

  1. 26 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Apr 23, 2026

React MTF Example

#696 Bundle Size — 196.39KiB (0%).

65f6f3c(current) vs 4643248 main#695(baseline)

Bundle metrics  no changes
                 Current
#696
     Baseline
#695
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 3 3
No change  Modules 173 173
No change  Duplicate Modules 66 66
No change  Duplicate Code 44.07% 44.07%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#696
     Baseline
#695
No change  IMG 111.23KiB 111.23KiB
No change  Other 85.15KiB 85.15KiB

Bundle analysis reportBranch PupilTong:p/hw/fix-css-og-add-cl...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Apr 23, 2026

React Example

#7564 Bundle Size — 225.23KiB (0%).

65f6f3c(current) vs 4643248 main#7563(baseline)

Bundle metrics  no changes
                 Current
#7564
     Baseline
#7563
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 4 4
No change  Modules 179 179
No change  Duplicate Modules 69 69
No change  Duplicate Code 44.57% 44.57%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#7564
     Baseline
#7563
No change  IMG 145.76KiB 145.76KiB
No change  Other 79.47KiB 79.47KiB

Bundle analysis reportBranch PupilTong:p/hw/fix-css-og-add-cl...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Apr 23, 2026

React External

#682 Bundle Size — 679.93KiB (0%).

65f6f3c(current) vs 4643248 main#681(baseline)

Bundle metrics  no changes
                 Current
#682
     Baseline
#681
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 3 3
No change  Modules 17 17
No change  Duplicate Modules 5 5
No change  Duplicate Code 8.59% 8.59%
No change  Packages 0 0
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#682
     Baseline
#681
No change  Other 679.93KiB 679.93KiB

Bundle analysis reportBranch PupilTong:p/hw/fix-css-og-add-cl...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Apr 23, 2026

Web Explorer

#9136 Bundle Size — 900.2KiB (+0.01%).

65f6f3c(current) vs 4643248 main#9135(baseline)

Bundle metrics  Change 3 changes
                 Current
#9136
     Baseline
#9135
No change  Initial JS 44.46KiB 44.46KiB
No change  Initial CSS 2.22KiB 2.22KiB
Change  Cache Invalidation 8.1% 0%
No change  Chunks 9 9
No change  Assets 11 11
Change  Modules 230(+0.44%) 229
No change  Duplicate Modules 11 11
Change  Duplicate Code 27.28%(-0.04%) 27.29%
No change  Packages 10 10
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Regression 1 regression
                 Current
#9136
     Baseline
#9135
Regression  JS 496.06KiB (+0.02%) 495.97KiB
No change  Other 401.92KiB 401.92KiB
No change  CSS 2.22KiB 2.22KiB

Bundle analysis reportBranch PupilTong:p/hw/fix-css-og-add-cl...Project dashboard


Generated by RelativeCIDocumentationReport issue

@PupilTong PupilTong merged commit 8352530 into lynx-family:main Apr 23, 2026
103 of 111 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants