From 6c44a511782ef8430f9464c7c6e7ee694be4afb3 Mon Sep 17 00:00:00 2001 From: John Hildenbiddle Date: Fri, 26 Jan 2018 00:22:03 -0800 Subject: [PATCH] Initial commit --- .eslintrc.js | 39 + .gitignore | 11 + .travis.yml | 13 + CHANGELOG.md | 7 + LICENSE | 2 +- dist/css-vars-ponyfill.esm.js | 979 +++ dist/css-vars-ponyfill.esm.js.map | 1 + dist/css-vars-ponyfill.esm.min.js | 16 + dist/css-vars-ponyfill.esm.min.js.map | 1 + dist/css-vars-ponyfill.js | 958 +++ dist/css-vars-ponyfill.js.map | 1 + dist/css-vars-ponyfill.min.js | 16 + dist/css-vars-ponyfill.min.js.map | 1 + karma.conf.js | 186 + package-lock.json | 9160 +++++++++++++++++++++++++ package.json | 80 + rollup.config.js | 143 + saucelabs.config.js | 6 + src/index.js | 249 + src/merge-deep.js | 36 + src/parse-css.js | 255 + src/stringify-css.js | 102 + src/transform-css.js | 314 + tests/.eslintrc.js | 20 + tests/css-vars.test.js | 454 ++ tests/fixtures/test-declaration.css | 3 + tests/fixtures/test-onerror.css | 1 + tests/fixtures/test-parse.css | 210 + tests/fixtures/test-stringify.css | 96 + tests/fixtures/test-value.css | 3 + tests/helpers/load-fixtures.js | 34 + tests/parse-css.test.js | 130 + tests/stringify-css.test.js | 47 + tests/transform-css.test.js | 326 + 34 files changed, 13899 insertions(+), 1 deletion(-) create mode 100644 .eslintrc.js create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 CHANGELOG.md create mode 100644 dist/css-vars-ponyfill.esm.js create mode 100644 dist/css-vars-ponyfill.esm.js.map create mode 100644 dist/css-vars-ponyfill.esm.min.js create mode 100644 dist/css-vars-ponyfill.esm.min.js.map create mode 100644 dist/css-vars-ponyfill.js create mode 100644 dist/css-vars-ponyfill.js.map create mode 100644 dist/css-vars-ponyfill.min.js create mode 100644 dist/css-vars-ponyfill.min.js.map create mode 100644 karma.conf.js create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 rollup.config.js create mode 100644 saucelabs.config.js create mode 100644 src/index.js create mode 100644 src/merge-deep.js create mode 100644 src/parse-css.js create mode 100644 src/stringify-css.js create mode 100644 src/transform-css.js create mode 100644 tests/.eslintrc.js create mode 100644 tests/css-vars.test.js create mode 100644 tests/fixtures/test-declaration.css create mode 100644 tests/fixtures/test-onerror.css create mode 100644 tests/fixtures/test-parse.css create mode 100644 tests/fixtures/test-stringify.css create mode 100644 tests/fixtures/test-value.css create mode 100644 tests/helpers/load-fixtures.js create mode 100644 tests/parse-css.test.js create mode 100644 tests/stringify-css.test.js create mode 100644 tests/transform-css.test.js diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..078213f --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,39 @@ +module.exports = { + "env": { + "browser" : true, + "commonjs": true, + "es6" : true, + "node" : true + }, + "extends": "eslint:recommended", + "plugins": [], + "parserOptions": { + "sourceType" : "module" + }, + "rules": { + "array-bracket-spacing" : ["error", "never"], + "array-callback-return" : ["error"], + "block-scoped-var" : ["error"], + "block-spacing" : ["error", "always"], + "curly" : ["error"], + "dot-notation" : ["error"], + "eqeqeq" : ["error"], + "indent" : ["error", 4], + "linebreak-style" : ["error", "unix"], + "no-console" : ["warn"], + "no-floating-decimal" : ["error"], + "no-implicit-coercion" : ["error"], + "no-implicit-globals" : ["error"], + "no-loop-func" : ["error"], + "no-return-assign" : ["error"], + "no-template-curly-in-string": ["error"], + "no-unneeded-ternary" : ["error"], + "no-unused-vars" : ["error", { "args": "none" }], + "no-useless-computed-key" : ["error"], + "no-useless-return" : ["error"], + "no-var" : ["error"], + "prefer-const" : ["error"], + "quotes" : ["error", "single"], + "semi" : ["error", "always"] + } +}; diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4a18cb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +# Folders +coverage +node_modules + +# Files +*.log + +# OS +._* +.cache +.DS_Store diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..4c9ee20 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,13 @@ +language: node_js +node_js: "stable" + +notifications: + email: false + +before_install: + - stty cols 80 + +script: "npm run test-remote" + +after_success: + - bash <(curl -s https://codecov.io/bash) -e TRAVIS_NODE_VERSION diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..28bcc51 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Change Log + +## 1.0.0 - 2017-11-26 + +**Added** + +- Initial release diff --git a/LICENSE b/LICENSE index cdce62f..51e689f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 John Hildenbiddle +Copyright (c) 2018 John Hildenbiddle Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/dist/css-vars-ponyfill.esm.js b/dist/css-vars-ponyfill.esm.js new file mode 100644 index 0000000..d77d379 --- /dev/null +++ b/dist/css-vars-ponyfill.esm.js @@ -0,0 +1,979 @@ +/*! + * css-vars-ponyfill + * v0.0.1 + * https://github.com/jhildenbiddle/css-vars-ponyfill + * (c) 2018 John Hildenbiddle + * MIT license + */ +/*! + * get-css-data + * v1.1.1 + * https://github.com/jhildenbiddle/get-css-data + * (c) 2018 John Hildenbiddle + * MIT license + */ +function getUrls(urls) { + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + var settings = { + mimeType: options.mimeType || null, + onComplete: options.onComplete || Function.prototype, + onError: options.onError || Function.prototype, + onSuccess: options.onSuccess || Function.prototype + }; + var urlArray = Array.isArray(urls) ? urls : [ urls ]; + var urlQueue = Array.apply(null, Array(urlArray.length)).map(function(x) { + return null; + }); + function onError(xhr, urlIndex) { + settings.onError(xhr, urlArray[urlIndex], urlIndex); + } + function onSuccess(responseText, urlIndex) { + urlQueue[urlIndex] = responseText; + settings.onSuccess(responseText, urlArray[urlIndex], urlIndex); + if (urlQueue.indexOf(null) === -1) { + settings.onComplete(urlQueue); + } + } + urlArray.forEach(function(url, i) { + var parser = document.createElement("a"); + parser.setAttribute("href", url); + parser.href = parser.href; + var isCrossDomain = parser.host !== location.host; + var isSameProtocol = parser.protocol === location.protocol; + if (isCrossDomain && typeof XDomainRequest !== "undefined") { + if (isSameProtocol) { + var xdr = new XDomainRequest(); + xdr.open("GET", url); + xdr.timeout = 0; + xdr.onprogress = Function.prototype; + xdr.ontimeout = Function.prototype; + xdr.onload = function() { + onSuccess(xdr.responseText, i); + }; + xdr.onerror = function(err) { + onError(xdr, i); + }; + setTimeout(function() { + xdr.send(); + }, 0); + } else { + console.log("Internet Explorer 9 Cross-Origin (CORS) requests must use the same protocol"); + onError(null, i); + } + } else { + var xhr = new XMLHttpRequest(); + xhr.open("GET", url); + if (settings.mimeType && xhr.overrideMimeType) { + xhr.overrideMimeType(settings.mimeType); + } + xhr.onreadystatechange = function() { + if (xhr.readyState === 4) { + if (xhr.status === 200) { + onSuccess(xhr.responseText, i); + } else { + onError(xhr, i); + } + } + }; + xhr.send(); + } + }); +} + +/** + * Gets CSS data from