Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d680f1f

Browse filesBrowse files
authored
fix(useCssVar): update variable when initial (#4641)
1 parent 73e6db2 commit d680f1f
Copy full SHA for d680f1f

File tree

2 files changed

+9
-0
lines changed
Filter options

2 files changed

+9
-0
lines changed

‎packages/core/useCssVar/index.test.ts

Copy file name to clipboardExpand all lines: packages/core/useCssVar/index.test.ts
+8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ describe('useCssVar', () => {
1919
expect(el.style.getPropertyValue(color)).toBe('red')
2020
})
2121

22+
it('should work with css variables', () => {
23+
document.documentElement.style.setProperty('--rootColor', 'red')
24+
25+
const colorNoRef = useCssVar('--rootColor')
26+
27+
expect(colorNoRef.value).toBe('red')
28+
})
29+
2230
it('should use window.document.documentElement as default element if not set', async () => {
2331
const vm = mount(defineComponent({
2432
setup() {

‎packages/core/useCssVar/index.ts

Copy file name to clipboardExpand all lines: packages/core/useCssVar/index.ts
+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export function useCssVar(
5555
old[0].style.removeProperty(old[1])
5656
updateCssVar()
5757
},
58+
{ immediate: true },
5859
)
5960

6061
watch(

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.