CSS Variables polyfill
Clone or download
Latest commit 0caa4ee Aug 19, 2014
Type Name Latest commit message Commit time
Failed to load latest commit information.
test fix #1 Aug 19, 2014
.gitignore cleanup repo Aug 19, 2014
.travis.yml cleanup repo Aug 19, 2014
LICENSE init Apr 30, 2014
README.md cleanup repo Aug 19, 2014
index.js fix #1 Aug 19, 2014
package.json 1.0.1 Aug 19, 2014


CSS Variables

NPM version Build status Test coverage Dependency Status License Downloads Gittip

A pure regexp-replace version of rework-vars. Differences are:

  • It doesn't use rework or parse the CSS AST
  • It does not remove variable declarations
  • It is much less robust
  • It does not throw error messages

Like rework-vars, it only implements a subset of CSS variables.


var variables = require('variables')

css = variables(css)

Do CSS variables magic.

map = variables.parse([map])

Parse CSS variables on :root, storing the variable values in map. Variable names do not include the leading --s.

re = variables.compile(map)

Compile a regular expression for matching var(--<name>)s with names given from map. This regular expression do not match var()s with fallbacks.

css = variables.replace(css, map)

Replace variables in css with a variable map.