You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-2Lines changed: 1 addition & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,8 +10,7 @@
10
10
11
11
A [ponyfill](https://ponyfill.com/) that provides client-side support for [CSS custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/--*) (aka "CSS variables") in legacy and modern browsers.
Copy file name to clipboardExpand all lines: docs/index.md
+35-16Lines changed: 35 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,8 +10,6 @@
10
10
11
11
A [ponyfill](https://ponyfill.com/) that provides client-side support for [CSS custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/--*) (aka "CSS variables") in legacy and modern browsers.
This library is offered as a [ponyfill](https://ponyfill.com/), not a polyfill. As a result, a function must be called in order for processing to take place.
69
-
70
81
```js
71
82
/* main.js */
72
83
@@ -75,17 +86,21 @@ cssVars({
75
86
});
76
87
```
77
88
89
+
## Usage
90
+
91
+
*This library is offered as a [ponyfill](https://ponyfill.com/), not a polyfill. This means that the `cssVars()` function must be called at least once in order for processing to take place (see [demos](#demos) and [installation](#installation) for details).*
92
+
78
93
For each `<link>` and `<style>` element processed the ponyfill will:
79
94
80
95
1. Get the CSS content (including `@import` rules)
81
-
1. Parse the CSS and convert it to an AST
82
-
1. Parse custom property declarations from `:root` and `:host` rulesets
83
-
1. Transform CSS `var()` functions to static values
84
-
1. Transforms relative `url()` paths to absolute URLs
85
-
1. Fix nested `calc()` functions
86
-
1. Convert the AST back to CSS
87
-
1. Append legacy-compatible CSS to the DOM
88
-
1. Disable the original stylesheet if styles are no longer needed
96
+
2. Parse the CSS and convert it to an AST
97
+
3. Parse custom property declarations from `:root` and `:host` rulesets
98
+
4. Transform CSS `var()` functions to static values
99
+
5. Transforms relative `url()` paths to absolute URLs
100
+
6. Fix nested `calc()` functions
101
+
7. Convert the AST back to CSS
102
+
8. Append legacy-compatible CSS to the DOM
103
+
9. Disable the original stylesheet if styles are no longer needed
89
104
90
105
Example:
91
106
@@ -920,10 +935,14 @@ cssVars({
920
935
921
936
-**Will the ponyfill support any of the above scenarios in the future?**
922
937
923
-
From [this comment](https://github.com/jhildenbiddle/css-vars-ponyfill/issues/31#issuecomment-527674559):
938
+
Probably not. See [this comment](https://github.com/jhildenbiddle/css-vars-ponyfill/issues/31#issuecomment-527674559) from [#31](https://github.com/jhildenbiddle/css-vars-ponyfill/issues/31):
924
939
925
940
> I also have to consider the fact that as time marches on, legacy browser support becomes less of an issue and so it becomes harder to justify time spent supporting them. If feedback proved that this was a critical issue for folks or if we were having this discussion in 2014/2015, I'd be much more likely to take on the work. Since neither of those are the case, it seems focusing on other tasks is a better use of time. That being said, I would be happy to review and assist with a PR if someone else wanted to have a go at it.
926
941
942
+
-**How can I conditionally load the ponyfill?**
943
+
944
+
See [this comment](https://github.com/jhildenbiddle/css-vars-ponyfill/issues/64#issuecomment-474233684) from [#64](https://github.com/jhildenbiddle/css-vars-ponyfill/issues/64).
945
+
927
946
## Attribution
928
947
929
948
This ponyfill includes code based on the following projects. Many thanks to the authors and contributors for helping to make this project possible.
0 commit comments