Skip to content

Commit 34e7c20

Browse files
committed
v1.2
- Update findSetters regex and add external test https://regex101.com/r/kWwUmp/3 (some day I will learn to write test cases) - `let` to `var` for better old browser support
1 parent 8ca9bad commit 34e7c20

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ This is an attempt at a very basic [CSS variables (custom properties)](https://d
66
According to [caniuse.com](https://caniuse.com/#feat=css-variables), of current browsers only IE, Edge and Opera Mini do not support CSS variables. This polyfill appears to work on all three really well. I don't see why this wouldn't work on older browsers as well, but I haven't been able to test it on them yet.
77

88
# Changelog
9+
## 1.2 - 2021-03-19
10+
- Update findSetters regex and add external test https://regex101.com/r/kWwUmp/3 (some day I will learn to write test cases)
11+
- `let` to `var` for better old browser support
12+
913
## 1.1.2 - 2019-03-23
1014
- Update findSetters and replaceGetters (thanks @CodeZeno)
1115

css-var-polyfill.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*!
2-
* css-var-polyfill.js - v1.1.2
2+
* css-var-polyfill.js - v1.2
33
*
44
* Copyright (c) 2019 Aaron Barker <http://aaronbarker.net>
55
* Released under the MIT license
66
*
7-
* Date: 2019-03-23
7+
* Date: 2021-03-19
88
*/
99
let cssVarPoly = {
1010
init: function() {
@@ -63,7 +63,8 @@ let cssVarPoly = {
6363
// find all the "--variable: value" matches in a provided block of CSS and add them to the master list
6464
findSetters: function(theCSS, counter) {
6565
// console.log(theCSS);
66-
cssVarPoly.varsByBlock[counter] = theCSS.match(/(--[^:)]+:[\s]*[^;}]+)/g) || [];
66+
// tests for the following at https://regex101.com/r/kWwUmp/3
67+
cssVarPoly.varsByBlock[counter] = theCSS.match(/(--[\w-]+:[\s]*[^;\n}]+)/g) || [];
6768
},
6869

6970
// run through all the CSS blocks to update the variables and then inject on the page

0 commit comments

Comments
 (0)