Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

css-var-shim

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-var-shim - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

4

CHANGELOG.md
# Change Log
This project adheres to [Semantic Versioning](http://semver.org/).
## 0.2.4 - 2017-08-30
### Added
- Added stylesheet filter by css file name
## 0.2.3 - 2017-08-30

@@ -5,0 +9,0 @@ ### Added

2

index.js

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.cssVarShim=e()}(this,function(){"use strict";function t(t,e){return(e=e||document).querySelectorAll(t)}function e(t){return c(t).reduce(function(t,n){return t.concat(n.cssRules?e(n.cssRules):n)},[])}function n(t,e,n){n=n||[];for(var r;null!==(r=e.exec(t));)n.push(r),e.lastIndex=r.index+r[0].length;return n}function r(t){return function(e){t.apply(this,e)}}function o(t,e){return e.reduce(function(t,e){return t?t[e]:void 0},t)}function u(t){return t=t||{},function(e){return t[e]=isNaN(t[e])?0:t[e]+1,t[e]}}function c(t){return[].slice.call(t)}function i(t){"loading"!==document.readyState?t():document.addEventListener("DOMContentLoaded",t)}function a(){var t={};return function(e,n){return e?n?(t[e]=n,n):t[e]:t}}function l(t){return function(){return c(arguments).reduce(function(e,n){return n?"object"==typeof n?e+f(n,t):e+n:e},"")}}function f(t,e){if(t[e])return t[e];var n=++p;return t[e]=n,n}function s(t){return t?t.replace(/\s+/g," ").replace(/"/g,"'").trim():""}var p=0;return function(f){function p(t,e){var r=n(t,/--[^\s,)]+/g);return r.length&&r.forEach(function(n){var r=n[0],o=d(r,e);if(o){var u=new RegExp("var\\("+r+"(,[^)]+)?\\)");t=t.replace(u,o),t=p(t,e)}}),t}function d(t,e){for(var n=S(v(t,e));!n&&e&&e.parentElement;)e=e.parentElement,n=S(v(t,e));return n}function y(e,n,r,o){var u=[document.documentElement];o&&":root"===o||(u=t(o)),c(u).forEach(function(t){var o=t!==document.documentElement?t:null;t.style.setProperty(e,n,r||null,o)})}if(!(window.CSS&&CSS.supports&&CSS.supports("--a",0))){var v=l("wl__uuid"),S=a(),h=CSSStyleDeclaration.prototype.getPropertyValue;CSSStyleDeclaration.prototype.getPropertyValue=function(t,e){return/^--/.test(t)?d(t,e):h.call(this,t)};var m=CSSStyleDeclaration.prototype.setProperty;CSSStyleDeclaration.prototype.setProperty=function(i,a,l,d){if(/^--/.test(i)){S(v(i,d),a);var y=u();e(document.styleSheets).forEach(function(e){var u=s(e.selectorText),a=y(u),l=o(f.getVars,[i,u,a]);if(!l){var v=n(u,/\.[\w-]+(\.[\w-]+)+/g);v.length&&(v.forEach(function(t){var e=t[0],n="."+e.slice(1).split(".").reverse().join(".");u=u.replace(e,n)}),l=o(f.getVars,[i,u,a]))}l&&l.forEach(r(function(n,r,o){var i=p(r,d);d?c(t(u)).forEach(function(t){d.contains(t)&&t.style.setProperty(n,i,o||null)}):e.style.setProperty(n,i,o||null)}))})}else m.call(this,i,a,l)},f.setVars.forEach(r(y)),i(function(){c(t('[data-style*="--"]')).forEach(function(t){var e=n(t.getAttribute("data-style"),/(--[^:]+)\s*:\s*([^;]+)/g);e.length&&e.forEach(r(function(e,n,r){t.style.setProperty(n,r,null,t)}))})})}}});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.cssVarShim=e()}(this,function(){"use strict";function t(t,e){return(e=e||document).querySelectorAll(t)}function e(t,e){return e?i(t).filter(function(t){return t.href&&-1!==t.href.indexOf(e)}):i(t)}function n(t){return i(t).reduce(function(t,e){return t.concat(e.cssRules?n(e.cssRules):e)},[])}function r(t,e,n){n=n||[];for(var r;null!==(r=e.exec(t));)n.push(r),e.lastIndex=r.index+r[0].length;return n}function o(t){return function(e){t.apply(this,e)}}function u(t,e){return e.reduce(function(t,e){return t?t[e]:void 0},t)}function c(t){return t=t||{},function(e){return t[e]=isNaN(t[e])?0:t[e]+1,t[e]}}function i(t){return[].slice.call(t)}function a(t){"loading"!==document.readyState?t():document.addEventListener("DOMContentLoaded",t)}function f(){var t={};return function(e,n){return e?n?(t[e]=n,n):t[e]:t}}function l(t){return function(){return i(arguments).reduce(function(e,n){return n?"object"==typeof n?e+s(n,t):e+n:e},"")}}function s(t,e){if(t[e])return t[e];var n=++d;return t[e]=n,n}function p(t){return t?t.replace(/\s+/g," ").replace(/"/g,"'").trim():""}var d=0;return function(s,d){function y(t,e){var n=r(t,/--[^\s,)]+/g);return n.length&&n.forEach(function(n){var r=n[0],o=h(r,e);if(o){var u=new RegExp("var\\("+r+"(,[^)]+)?\\)");t=t.replace(u,o),t=y(t,e)}}),t}function h(t,e){for(var n=m(S(t,e));!n&&e&&e.parentElement;)e=e.parentElement,n=m(S(t,e));return n}function v(e,n,r,o){var u=[document.documentElement];o&&":root"===o||(u=t(o)),i(u).forEach(function(t){var o=t!==document.documentElement?t:null;t.style.setProperty(e,n,r||null,o)})}if(!(window.CSS&&CSS.supports&&CSS.supports("--a",0))){var S=l("wl__uuid"),m=f(),g=CSSStyleDeclaration.prototype.getPropertyValue;CSSStyleDeclaration.prototype.getPropertyValue=function(t,e){return/^--/.test(t)?h(t,e):g.call(this,t)};var E=CSSStyleDeclaration.prototype.setProperty;CSSStyleDeclaration.prototype.setProperty=function(a,f,l,h){if(/^--/.test(a)){m(S(a,h),f);var v=c();n(e(document.styleSheets,d)).forEach(function(e){var n=p(e.selectorText),c=v(n),f=u(s.getVars,[a,n,c]);if(!f){var l=r(n,/\.[\w-]+(\.[\w-]+)+/g);l.length&&(l.forEach(function(t){var e=t[0],r="."+e.slice(1).split(".").reverse().join(".");n=n.replace(e,r)}),f=u(s.getVars,[a,n,c]))}f&&f.forEach(o(function(r,o,u){var c=y(o,h);h?i(t(n)).forEach(function(t){h.contains(t)&&t.style.setProperty(r,c,u||null)}):e.style.setProperty(r,c,u||null)}))})}else E.call(this,a,f,l)},s.setVars.forEach(o(v)),a(function(){i(t('[data-style*="--"]')).forEach(function(t){var e=r(t.getAttribute("data-style"),/(--[^:]+)\s*:\s*([^;]+)/g);e.length&&e.forEach(o(function(e,n,r){t.style.setProperty(n,r,null,t)}))})})}}});
{
"name": "css-var-shim",
"version": "0.2.3",
"version": "0.2.4",
"description": "A shim to provide basic functionality to IE/Edge for changing custom CSS properties at runtime.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1,4 +0,4 @@

import { qsa, getCssRules, getMatches, niceArguments, objectResolve, makeCount, arrayFrom, ready, makeCache, makeKey, cleanCss } from './utils';
import { qsa, getCssRules, getSheetsByName, getMatches, niceArguments, objectResolve, makeCount, arrayFrom, ready, makeCache, makeKey, cleanCss } from './utils';
function cssVarShim(cssVarMap) {
function cssVarShim(cssVarMap, cssFileName) {
var cssVarSupport = window.CSS && CSS.supports && CSS.supports('--a', 0);

@@ -49,3 +49,3 @@ if (cssVarSupport) {

var count = makeCount();
var cssRules = getCssRules(document.styleSheets);
var cssRules = getCssRules(getSheetsByName(document.styleSheets, cssFileName));
cssRules.forEach(function (rule) {

@@ -52,0 +52,0 @@ var selector = cleanCss(rule.selectorText);

@@ -7,2 +7,11 @@

export function getSheetsByName(sheets, cssFileName) {
if (cssFileName) {
return arrayFrom(sheets).filter(function (sheet) {
return sheet.href && sheet.href.indexOf(cssFileName) !== -1;
});
}
return arrayFrom(sheets);
}
export function getCssRules(cssRulesObject) {

@@ -9,0 +18,0 @@ return arrayFrom(cssRulesObject).reduce(function (prev, curr) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc