Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Preserve supported runtime rules when the browser rejects CSSOM nodes

未关闭
#462 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
css, typescript

调研方向

Start with packages/runtime/src/layer.ts, host.ts, and core.ts, then reproduce the mixed manifest case in Chromium or WebKit. Read the existing correctness-regressions.test.ts case named “hydration rejects CSSOM nodes dropped by the browser” and add focused coverage for rejected nodes around supported rules. Done means supported 21px styling survives rendering, hydration, insertion, deletion, refresh, and fallback while mismatch checks remain strict.

由索引模型根据 Issue 内容生成。

描述

runtime

Problem and classification

P1 · Required for the 2.0 freeze. A browser-rejected selector can prevent a later, supported rule from being inserted. Progressive hydration can consequently remove styling that was already working in the server-rendered page.

Parent: #445. Implementation detail of the rendering-equivalence work in #451; completion evidence feeds #454. This issue adds a newly reproduced counterexample, not another general rendering audit.

Baseline: 70444b18c8102fa7a9d811ec51ef96902573792c. Reproduced locally on 2026-09-27 in Chromium and WebKit. The new counterexample has not been run in Firefox. Concurrent local freeze documentation/tests are unrelated and must be preserved.

Reproduction and observed behavior

Use this public execution manifest with an element whose class is mixed:

const manifest = {
  version: 1,
  languageVersion: 3,
  utilities: [{
    id: 'mixed',
    name: 'mixed',
    type: 0,
    matchers: [{ type: 'static', name: 'mixed' }],
    emit: {
      type: 'static',
      rules: [
        { selector: '&:mastercss-unknown-pseudo', declarations: { color: 'red' } },
        { declarations: { width: '21px' } }
      ]
    }
  }]
}
const runtime = await MasterCSSRuntime.start({ manifest })
runtime.observe()

The engine correctly preserves both rules:

@layer utilities {
  .mixed:mastercss-unknown-pseudo { color: red }
  .mixed { width: 21px }
}
Path Observed result in both tested browsers
Load generated CSS directly The browser drops the unknown-selector rule; width is 21px.
Generate through runtime The first insertion throws SyntaxError; the second throws IndexSizeError; the layer is empty.
Hydrate the working SSR output Width changes from 21px to automatic width (1264px in the probe viewport). The engine snapshot still contains both rules.

The existing correctness-regressions.test.ts case named “hydration rejects CSSOM nodes dropped by the browser” does not exercise a rejected node preceding a supported node in this multi-node output.

Cause and source evidence

  • layer.ts increments offsets and node counts before insertion, using expected output node counts.
  • host.ts continues with nativeIndex + nodeIndex after a failed insertion; deletion also assumes all expected nodes exist.
  • core.ts requires browser node counts to equal engine node counts during hydration.

CSSOM permits parsing to fail and requires an index beyond the current rule count to fail separately.

Implementation plan

  • Keep Rust rules, ordering, resource ownership and generated CSS unchanged. Do not restore host-support filtering or add a runtime CSS grammar validator.
  • Separate logical rule/node identity from successful CSSOM attachment. Each generated node may have zero or one attached top-level CSSOM node; a logical rule can have multiple generated nodes. Compute insertion/deletion offsets from actual attachments.
  • Make insertion failures local to the rejected node. Preserve supported siblings and subsequent rules in Rust order. Distinguish browser parsing rejection from internal index/bookkeeping errors; do not label every exception as unsupported CSS.
  • Delete only nodes actually owned by the removed rule. A rejected node must never consume an adjacent rule's deletion slot.
  • Build the same attachment mapping for fresh rendering, snapshot adoption, refresh, hydration and fallback. Match the browser-parsed projection while retaining strict checks for changed, extra, missing, duplicated or reordered supported rules/resources. Removing the node-count assertion alone is insufficient.
  • Preserve complete engine snapshots and resource accounting. Browser omission must not change semantic output or masquerade as successful physical insertion.
  • Add permanent focused regressions and document the distinction between generated CSS and browser-attached CSS. This is a runtime correctness fix, not a class-language change.

Acceptance and validation

  • Rejected nodes before, between and after supported nodes work within one multi-node rule and across separate rules.
  • Insert/delete/reinsert, shared classes, refresh, retention cleanup and last-reference removal preserve unrelated styles and resources.
  • Static, SSR, runtime and progressive paths retain the supported 21px declaration. Hydration and later DOM changes do not introduce style loss.
  • Cover unknown selectors and browser-dropped contents inside wrappers, supported siblings, all utility layers, Document and ShadowRoot.
  • Existing hydration tampering tests continue to reject actual mismatches.
  • Run focused and then affected runtime e2e in Chromium, WebKit and Firefox; report unrun/environment-blocked cases honestly. Run runtime lint, type-check and build, and relevant server/hydration tests.
  • Measure runtime insertion/deletion/hydration hot paths and complete runtime JS/Wasm/manifest payload against the same baseline/workload. Remeasure regressions above 5% and explain the cost; do not recover speed by weakening matching.

Boundaries and integration

No new syntax, Manifest/hydration wire shape, browser-support database, compiler fallback or release/CI changes are intended. The nonce/atomic-delivery follow-up #463 shares hydration code; land this mapping work first, then integrate #463 and run their combined matrix once. Add results to #451 and #454 rather than duplicating their broader audits. Preserve the ongoing #445 worktree changes.

主要语言
TypeScript
星标
2k
派生
44
平均合并
1 天 3 小时
30 天内合并 PR
1

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

master-co/css 的其他 Issue

查看 master-co/css 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。