Skip to content

Commit

Permalink
v1.2
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
aaronbarker committed Mar 20, 2021
1 parent 8ca9bad commit 34e7c20
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ This is an attempt at a very basic [CSS variables (custom properties)](https://d
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.

# Changelog
## 1.2 - 2021-03-19
- 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.1.2 - 2019-03-23
- Update findSetters and replaceGetters (thanks @CodeZeno)

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

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

0 comments on commit 34e7c20

Please sign in to comment.