Skip to content

fix: add nullish in dynamicCSS.ts - #455

Open
zerosrat wants to merge 3 commits into
react-component:masterfrom
zerosrat:master
Open

fix: add nullish in dynamicCSS.ts#455
zerosrat wants to merge 3 commits into
react-component:masterfrom
zerosrat:master

Conversation

@zerosrat

Copy link
Copy Markdown
Contributor

dynamicCSS.ts 内的判空处理

@vercel

vercel Bot commented Jul 26, 2023

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
util ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 26, 2023 2:29am
@codecov

codecov Bot commented Jul 26, 2023

Copy link
Copy Markdown

Codecov Report

Merging #455 (a18a9f9) into master (e909e6f) will increase coverage by 0.00%.
Report is 1 commits behind head on master.
The diff coverage is 100.00%.

❗ Current head a18a9f9 differs from pull request most recent head 903dfe1. Consider uploading reports for the commit 903dfe1 to get more accurate results

@@           Coverage Diff           @@
##           master     #455   +/-   ##
=======================================
  Coverage   91.41%   91.42%           
=======================================
  Files          38       38           
  Lines         897      898    +1     
  Branches      270      271    +1     
=======================================
+ Hits          820      821    +1     
  Misses         75       75           
  Partials        2        2           
Files Changed Coverage Δ
src/Dom/dynamicCSS.ts 97.29% <100.00%> (+0.03%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@veeramarni

Copy link
Copy Markdown

Anyone taking any action? This is breaking with remix and antd

@loamietom

Copy link
Copy Markdown

Is there anyway we can assist with the merge of this fix?

@nrps9909 nrps9909 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I tested the exact head 903dfe1c23c09fc41aa2fe5de0a3812fa35a8236 against a regression that temporarily removes both document.head and document.body, matching the window described in #603. This patch still throws on both public paths:

  • injectCSS(...): TypeError: Cannot read properties of null (reading 'appendChild') at container.appendChild(styleNode)
  • updateCSS(...): the same exception through syncRealContainer -> injectCSS

There is also a separate behavior regression in the prepend branch: insertBefore(styleNode, null) is the correct way to append into an empty valid container, but the new if (firstChild) guard leaves the returned style node detached when the container exists and is empty.

A complete fix needs to return null before injection when no container exists, and guard the updateCSS/container-sync path as well, while retaining the unconditional insertBefore(..., firstChild) after a non-null container has been established. I verified that shape against the full current suite (29 suites, 184 passed, 1 skipped), TypeScript, and lint.

AI assistance disclosure: Codex was used to trace the control flow, construct and run the exact-head regression, and draft this review; the failures above were executed locally against the cited commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants