Skip to content

fix: firefox @supports(width:1rex)#2288

Merged
PupilTong merged 2 commits intolynx-family:mainfrom
PupilTong:p/hw/fix-rex
Mar 3, 2026
Merged

fix: firefox @supports(width:1rex)#2288
PupilTong merged 2 commits intolynx-family:mainfrom
PupilTong:p/hw/fix-rex

Conversation

@PupilTong
Copy link
Copy Markdown
Collaborator

@PupilTong PupilTong commented Mar 2, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Fixed Firefox-specific CSS feature detection to ensure correct layout behavior.
  • Improvements

    • Strengthened browser capability detection for more reliable layout support.
    • Optimized linear/flex layout styles for improved cross-browser consistency and alignment.
  • New Features

    • Added a set of new custom CSS properties to enable finer control over linear/flex layout behavior.
  • Style

    • Adjusted stylesheet loading behavior to streamline style application at runtime.

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).

BTW:
Uploading img_v3_02vd_e15c6b29-a2d4-4c4d-8235-fd685c250c3g.jpg…

Copilot AI review requested due to automatic review settings March 2, 2026 09:53
@PupilTong PupilTong requested a review from Sherry-hue as a code owner March 2, 2026 09:53
@PupilTong PupilTong self-assigned this Mar 2, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 2, 2026

🦋 Changeset detected

Latest commit: 94c3b74

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

This PR includes changesets to release 2 packages
Name Type
@lynx-js/web-elements Patch
@lynx-js/web-core-wasm 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 Mar 2, 2026

📝 Walkthrough

Walkthrough

This PR updates CSS feature detection from width: 1rex to -webkit-box-reflect: above, adds multiple CSS Houdini @property declarations for linear/flex layout, consolidates flex shorthand usage, and changes where in-shadow CSS is injected between client entry points.

Changes

Cohort / File(s) Summary
Changeset Entry
\.changeset/crazy-views-sit.md
Added patch changeset for @lynx-js/web-elements documenting a Firefox-specific CSS feature-detection fix.
Compat & Common CSS Updates
packages/web-platform/web-elements/src/compat/LinearContainer/linear-compat.css, packages/web-platform/web-elements/src/elements/common-css/linear.css
Replaced @supports(width:1rex) gating with @supports(-webkit-box-reflect: above); added justify-content: flex-start in linear base; added align-self: var(--align-self-row) for horizontal orientation; tightened flex shorthand to flex: var(--flex, var(--flex-grow) var(--flex-shrink) var(--flex-basis)).
Houdini Custom Properties
packages/web-platform/web-elements/src/elements/common-css/linear.css
Introduced ~16 @property declarations (e.g., --lynx-linear-weight-sum, --flex-direction, --flex-grow, --flex-shrink, --flex-basis, --flex, --align-self-row/column, justify-content variants) with initial values and syntax for layout behavior.
Client runtime CSS injection
packages/web-platform/web-core-wasm/ts/client/mainthread/LynxViewInstance.ts, packages/web-platform/web-core-wasm/ts/client/mainthread/elementAPIs/createElementAPI.ts
Moved in-shadow CSS injection: added blob/link insertion in LynxViewInstance.ts and removed prior dynamic injection from createElementAPI.ts (transition of CSS-injection responsibility).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • Sherry-hue
  • colinaaa

Poem

🐰 I hop through styles with nimble cheer,
Replacing rex checks so Firefox steers clear,
New properties sprout, flex lines align,
Shadows find home where link tags shine,
A tiny rabbit celebrates layout divine.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title specifically references a Firefox-specific CSS feature detection fix involving @supports and width:1rex, which directly matches the primary changes across the PR (replacing width:1rex detection with webkit-box-reflect).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the feature-detection used to enable the @container style(...)-based linear/flex toggle logic so that Firefox does not accidentally match the @supports gate.

Changes:

  • Replace @supports (width: 1rex) gating with @supports (-webkit-box-reflect: above) to exclude Firefox.
  • Simplify nested var(...) formatting for flex-wrap, flex-direction, and flex declarations.
  • Add a patch changeset for @lynx-js/web-elements.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
packages/web-platform/web-elements/src/elements/common-css/linear.css Switches the @supports gate to -webkit-box-reflect and simplifies var(...) usage.
packages/web-platform/web-elements/src/compat/LinearContainer/linear-compat.css Mirrors the updated @supports not (...) condition for the fallback compat rules.
.changeset/crazy-views-sit.md Adds a patch changeset describing the fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 2, 2026

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...core-wasm/ts/client/mainthread/LynxViewInstance.ts 90.00% 1 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/web-platform/web-elements/src/compat/LinearContainer/linear-compat.css (1)

103-123: ⚠️ Potential issue | 🟡 Minor

Missing > * child combinator on reverse orientation selectors.

Lines 104 and 115 are missing the > * suffix, causing align-self to be applied to the container instead of its children. The align-self property should target flex items (children), not the flex container.

🐛 Proposed fix
   [lynx-computed-display="linear"][lynx-linear-orientation="vertical"] > *,
-  [lynx-computed-display="linear"][lynx-linear-orientation="vertical-reverse"],
+  [lynx-computed-display="linear"][lynx-linear-orientation="vertical-reverse"] > *,
   [lynx-computed-display="linear"][lynx-linear-orientation="vertical"]
     > lynx-wrapper
     > *,
   [lynx-computed-display="linear"][lynx-linear-orientation="vertical-reverse"]
     > lynx-wrapper
     > * {
     align-self: var(--align-self-column);
   }

   [lynx-computed-display="linear"][lynx-linear-orientation="horizontal"] > *,
-  [lynx-computed-display="linear"][lynx-linear-orientation="horizontal-reverse"],
+  [lynx-computed-display="linear"][lynx-linear-orientation="horizontal-reverse"] > *,
   [lynx-computed-display="linear"][lynx-linear-orientation="horizontal"]
     > lynx-wrapper
     > *,
   [lynx-computed-display="linear"][lynx-linear-orientation="horizontal-reverse"]
     > lynx-wrapper
     > * {
     align-self: var(--align-self-row);
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/web-platform/web-elements/src/compat/LinearContainer/linear-compat.css`
around lines 103 - 123, The selectors for vertical-reverse and
horizontal-reverse (e.g.,
[lynx-computed-display="linear"][lynx-linear-orientation="vertical-reverse"] and
[lynx-computed-display="linear"][lynx-linear-orientation="horizontal-reverse"])
are missing the child combinator suffix "> *", causing align-self to apply to
the container instead of its children; update those reverse-orientation
selectors so they target the children (including the lynx-wrapper > * variant)
and use align-self: var(--align-self-column) or var(--align-self-row)
respectively to match the non-reverse selectors.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In
`@packages/web-platform/web-elements/src/compat/LinearContainer/linear-compat.css`:
- Around line 103-123: The selectors for vertical-reverse and horizontal-reverse
(e.g.,
[lynx-computed-display="linear"][lynx-linear-orientation="vertical-reverse"] and
[lynx-computed-display="linear"][lynx-linear-orientation="horizontal-reverse"])
are missing the child combinator suffix "> *", causing align-self to apply to
the container instead of its children; update those reverse-orientation
selectors so they target the children (including the lynx-wrapper > * variant)
and use align-self: var(--align-self-column) or var(--align-self-row)
respectively to match the non-reverse selectors.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 88fbad8 and a2a36c5.

📒 Files selected for processing (3)
  • .changeset/crazy-views-sit.md
  • packages/web-platform/web-elements/src/compat/LinearContainer/linear-compat.css
  • packages/web-platform/web-elements/src/elements/common-css/linear.css

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 2, 2026

Merging this PR will improve performance by 6.23%

⚡ 3 improved benchmarks
✅ 69 untouched benchmarks
⏩ 3 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
basic-performance-div-100 7.4 ms 6.9 ms +6.23%
basic-performance-div-10000 485.4 ms 459.2 ms +5.71%
basic-performance-large-css 12.3 ms 11.7 ms +5.18%

Comparing PupilTong:p/hw/fix-rex (94c3b74) with main (8ca97fe)

Open in CodSpeed

Footnotes

  1. 3 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 Mar 2, 2026

Web Explorer

#7887 Bundle Size — 383.67KiB (~+0.01%).

94c3b74(current) vs 8ca97fe main#7876(baseline)

Bundle metrics  Change 3 changes Regression 1 regression
                 Current
#7887
     Baseline
#7876
No change  Initial JS 154.78KiB 154.78KiB
Regression  Initial CSS 35.09KiB(+0.08%) 35.06KiB
Change  Cache Invalidation 9.14% 0%
No change  Chunks 8 8
No change  Assets 8 8
Change  Modules 238(-0.42%) 239
No change  Duplicate Modules 16 16
No change  Duplicate Code 2.99% 2.99%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Regression 1 regression
                 Current
#7887
     Baseline
#7876
No change  JS 252.72KiB 252.72KiB
No change  Other 95.85KiB 95.85KiB
Regression  CSS 35.09KiB (+0.08%) 35.06KiB

Bundle analysis reportBranch PupilTong:p/hw/fix-rexProject dashboard


Generated by RelativeCIDocumentationReport issue

…from `createElementAPI` to `LynxViewInstance`.
@PupilTong PupilTong requested a review from colinaaa March 2, 2026 14:24
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 (2)
packages/web-platform/web-core-wasm/ts/client/mainthread/LynxViewInstance.ts (2)

93-93: Optionally guard against duplicate stylesheet insertion in reused shadow roots.

Line 93 appends a link on every construction. If the same ShadowRoot is reused, identical links can accumulate.

Suggested tweak
-    this.rootDom.append(linkElement.cloneNode(false));
+    if (!this.rootDom.querySelector('link[data-lynx-in-shadow]')) {
+      const inShadowLink = linkElement.cloneNode(false) as HTMLLinkElement;
+      inShadowLink.setAttribute('data-lynx-in-shadow', '');
+      this.rootDom.append(inShadowLink);
+    }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/web-platform/web-core-wasm/ts/client/mainthread/LynxViewInstance.ts`
at line 93, The constructor currently appends linkElement.cloneNode(false) to
this.rootDom every time, which can produce duplicate stylesheet <link> tags when
a ShadowRoot is reused; modify the code that appends the stylesheet (reference:
this.rootDom and linkElement usage in LynxViewInstance) to first check for an
existing equivalent <link> (e.g., by rel/href or a data-attribute) inside
this.rootDom and only append the cloned link if none is found, ensuring
deduplication when reusing the same ShadowRoot.

27-28: Replace broad @ts-expect-error with typed *.css?inline module declaration.

Line 27 disables strict checking for this import and can mask unrelated type issues. Prefer an ambient declaration (e.g., declare module '*.css?inline') and remove the suppression.

#!/bin/bash
# Verify whether a typed declaration already exists for `*.css?inline`
# and where this suppression is used.

fd -HI '\.d\.ts$' | xargs rg -n "declare module ['\"].*\\.css\\?inline['\"]|\\*\\.css\\?inline"
rg -n "@ts-expect-error|in_shadow\\.css\\?inline" packages/web-platform/web-core-wasm/ts/client/mainthread/LynxViewInstance.ts

As per coding guidelines, "**/*.{ts,tsx}: Use TypeScript with the strictest mode configuration as defined in tsconfig.json".

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

In `@packages/web-platform/web-core-wasm/ts/client/mainthread/LynxViewInstance.ts`
around lines 27 - 28, Remove the broad "// `@ts-expect-error`" before the CSS
inline import (import IN_SHADOW_CSS_MODERN ...) and instead add a proper ambient
module declaration for "*.css?inline" (e.g., declare module '*.css?inline' {
const content: string; export default content; }) in a new or existing .d.ts
file included by the TS compiler; then re-import IN_SHADOW_CSS_MODERN without
the suppression so the import is properly typed (update any tsconfig includes if
needed so the declaration is picked up).
🤖 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-wasm/ts/client/mainthread/LynxViewInstance.ts`:
- Line 93: The constructor currently appends linkElement.cloneNode(false) to
this.rootDom every time, which can produce duplicate stylesheet <link> tags when
a ShadowRoot is reused; modify the code that appends the stylesheet (reference:
this.rootDom and linkElement usage in LynxViewInstance) to first check for an
existing equivalent <link> (e.g., by rel/href or a data-attribute) inside
this.rootDom and only append the cloned link if none is found, ensuring
deduplication when reusing the same ShadowRoot.
- Around line 27-28: Remove the broad "// `@ts-expect-error`" before the CSS
inline import (import IN_SHADOW_CSS_MODERN ...) and instead add a proper ambient
module declaration for "*.css?inline" (e.g., declare module '*.css?inline' {
const content: string; export default content; }) in a new or existing .d.ts
file included by the TS compiler; then re-import IN_SHADOW_CSS_MODERN without
the suppression so the import is properly typed (update any tsconfig includes if
needed so the declaration is picked up).

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a2a36c5 and 94c3b74.

📒 Files selected for processing (2)
  • packages/web-platform/web-core-wasm/ts/client/mainthread/LynxViewInstance.ts
  • packages/web-platform/web-core-wasm/ts/client/mainthread/elementAPIs/createElementAPI.ts
💤 Files with no reviewable changes (1)
  • packages/web-platform/web-core-wasm/ts/client/mainthread/elementAPIs/createElementAPI.ts

@PupilTong PupilTong merged commit 8fd936a into lynx-family:main Mar 3, 2026
48 checks passed
colinaaa pushed a commit that referenced this pull request Mar 9, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @lynx-js/devtool-mcp-server@0.5.0

### Minor Changes

- Use `@lynx-js/devtool-connector` instead of
`@lynx-js/debug-router-connector`.
([#2284](#2284))

The new connector avoids using keep-alive connections, which makes the
connection much more reliable.

- **BREAKING CHANGE**: Remove the `./debug-router-connector` exports.
([#2284](#2284))

## @lynx-js/web-elements@0.12.0

### Minor Changes

- feat: add `willchange` event to `x-viewpager-ng`
([#2305](#2305))

### Patch Changes

- fix: firefox `@supports(width:1rex)`
([#2288](#2288))

- fix: check computed overflow style in `getTheMostScrollableKid` to
avoid treating `overflow: visible` elements as scroll containers
([#2309](#2309))

- fix: the inline-truncation should only work as a direct child of
x-text ([#2287](#2287))

- fix: getVisibleCells cannot work in firefox due to
contentvisibilityautostatechange not propagate list-item
([#2308](#2308))

- fix: foldview stuck issue
([#2304](#2304))

## @lynx-js/gesture-runtime@2.1.3

### Patch Changes

- Optimize gesture callbacks and relationships to prevent unnecessary
gesture registration and rerenders.
([#2277](#2277))

## @lynx-js/react@0.116.5

### Patch Changes

- Improve React runtime hook profiling.
([#2235](#2235))
Enable Profiling recording first, then enter the target page so the
trace includes full render/hydrate phases.

- Record trace events for `useEffect` / `useLayoutEffect` hook entry,
callback, and cleanup phases.
    -   Log trace events for `useState` setter calls.
- Wire `profileFlowId` support in debug profile utilities and attach
flow IDs to related hook traces.
- Instrument hydrate/background snapshot profiling around patch
operations with richer args (e.g. snapshot id/type, dynamic part index,
value type, and source when available).
- Capture vnode source mapping in dev and use it in profiling args to
improve trace attribution.
- Expand debug test coverage for profile utilities, hook profiling
behavior, vnode source mapping, and hydrate profiling branches.

- refactor: call loadWorkletRuntime once in each module
([#2315](#2315))

## @lynx-js/rspeedy@0.13.5

### Patch Changes

- feat: opt-in the web platform's new binary output format
([#2281](#2281))

    Introduce a new flag to enable the new binary output format.

Currently it's an internal-use-only flag that will be removed in the
future; set the corresponding environment variable to 'true' to enable
it.

- Avoid generating `Rsbuild vundefined` in greeting message.
([#2275](#2275))

-   Updated dependencies \[]:
    -   @lynx-js/web-rsbuild-server-middleware@0.19.8

## @lynx-js/lynx-bundle-rslib-config@0.2.2

### Patch Changes

- Support bundle and load css in external bundle
([#2143](#2143))

## @lynx-js/external-bundle-rsbuild-plugin@0.0.3

### Patch Changes

- Updated dependencies
\[[`c28b051`](c28b051),
[`4cbf809`](4cbf809)]:
    -   @lynx-js/externals-loading-webpack-plugin@0.0.4

## @lynx-js/react-rsbuild-plugin@0.12.10

### Patch Changes

- Support bundle and load css in external bundle
([#2143](#2143))

- Updated dependencies
\[[`59f2933`](59f2933),
[`453e006`](453e006)]:
    -   @lynx-js/template-webpack-plugin@0.10.5
    -   @lynx-js/css-extract-webpack-plugin@0.7.0
    -   @lynx-js/react-webpack-plugin@0.7.4
    -   @lynx-js/react-alias-rsbuild-plugin@0.12.10
    -   @lynx-js/use-sync-external-store@1.5.0
    -   @lynx-js/react-refresh-webpack-plugin@0.3.4

## @lynx-js/web-core-wasm@0.0.5

### Patch Changes

- Updated dependencies
\[[`4963907`](4963907),
[`8fd936a`](8fd936a),
[`0d41253`](0d41253),
[`d32c4c6`](d32c4c6),
[`7518b72`](7518b72),
[`fca9d4a`](fca9d4a)]:
    -   @lynx-js/web-elements@0.12.0

## @lynx-js/externals-loading-webpack-plugin@0.0.4

### Patch Changes

- perf: optimize external bundle loading by merging multiple
`fetchBundle` calls for the same URL into a single request.
([#2307](#2307))

- Support bundle and load css in external bundle
([#2143](#2143))

## @lynx-js/template-webpack-plugin@0.10.5

### Patch Changes

- feat: allow `templateDebugUrl` to be customized via
`output.publicPath` or the `beforeEncode` hook.
([#2274](#2274))

- feat: opt-in the web platform's new binary output format
([#2281](#2281))

    Introduce a new flag to enable the new binary output format.

Currently it's an internal-use-only flag that will be removed in the
future; set the corresponding environment variable to 'true' to enable
it.

-   Updated dependencies \[]:
    -   @lynx-js/web-core-wasm@0.0.5

## create-rspeedy@0.13.5



## @lynx-js/react-alias-rsbuild-plugin@0.12.10



## upgrade-rspeedy@0.13.5

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

3 participants