fix: add nullish in dynamicCSS.ts - #455
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov Report
@@ 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
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
Anyone taking any action? This is breaking with |
|
Is there anyway we can assist with the merge of this fix? |
nrps9909
left a comment
There was a problem hiding this comment.
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')atcontainer.appendChild(styleNode)updateCSS(...): the same exception throughsyncRealContainer -> 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.
dynamicCSS.ts 内的判空处理