Skip to content

Commit cb0228a

Browse files
fix(useCssVar): optimize target value tracking by changing targetHadValue to a primitive boolean
1 parent 40c496e commit cb0228a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/core/useCssVar/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ export function useCssVar(
3232
const variable = shallowRef(initialValue)
3333

3434
// Track if target has ever had a truthy value
35-
const targetHadValue = shallowRef(false)
35+
let targetHadValue = false
3636

3737
const elRef = computed(() => {
3838
const element = unrefElement(target)
3939

4040
if (element) {
41-
targetHadValue.value = true
41+
targetHadValue = true
4242
return element
4343
}
4444

4545
// If target never had a value, use documentElement as fallback
4646
// If target had a value but now is undefined, don't use fallback
47-
return targetHadValue.value ? null : window?.document?.documentElement
47+
return targetHadValue ? null : window?.document?.documentElement
4848
})
4949

5050
function updateCssVar() {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy