jss-plugin-global
Advanced tools
Comparing version 10.4.0 to 10.5.0
@@ -144,3 +144,3 @@ function _extends() { | ||
function toCssValue(value, ignoreImportant) { | ||
var toCssValue = function toCssValue(value, ignoreImportant) { | ||
if (ignoreImportant === void 0) { | ||
@@ -167,3 +167,3 @@ ignoreImportant = false; | ||
return cssValue; | ||
} | ||
}; | ||
/** | ||
@@ -455,7 +455,7 @@ * Indent a string. | ||
this.renderable = void 0; | ||
this.key = key; // Key might contain a unique suffix in case the `name` passed by user was duplicate. | ||
this.key = key; | ||
var atMatch = key.match(atRegExp); | ||
this.at = atMatch ? atMatch[1] : 'unknown'; // Key might contain a unique suffix in case the `name` passed by user was duplicate. | ||
this.query = options.name; | ||
var atMatch = key.match(atRegExp); | ||
this.at = atMatch ? atMatch[1] : 'unknown'; | ||
this.query = options.name || "@" + this.at; | ||
this.options = options; | ||
@@ -1012,9 +1012,9 @@ this.rules = new RuleList(_extends({}, options, { | ||
if (typeof (arguments.length <= 0 ? undefined : arguments[0]) === 'string') { | ||
name = arguments.length <= 0 ? undefined : arguments[0]; // $FlowFixMe | ||
name = arguments.length <= 0 ? undefined : arguments[0]; // $FlowFixMe[invalid-tuple-index] | ||
data = arguments.length <= 1 ? undefined : arguments[1]; // $FlowFixMe | ||
data = arguments.length <= 1 ? undefined : arguments[1]; // $FlowFixMe[invalid-tuple-index] | ||
options = arguments.length <= 2 ? undefined : arguments[2]; | ||
} else { | ||
data = arguments.length <= 0 ? undefined : arguments[0]; // $FlowFixMe | ||
data = arguments.length <= 0 ? undefined : arguments[0]; // $FlowFixMe[invalid-tuple-index] | ||
@@ -1246,3 +1246,9 @@ options = arguments.length <= 1 ? undefined : arguments[1]; | ||
var rule = typeof name === 'object' ? name : this.rules.get(name); | ||
if (!rule) return false; | ||
if (!rule || // Style sheet was created without link: true and attached, in this case we | ||
// won't be able to remove the CSS rule from the DOM. | ||
this.attached && !rule.renderable) { | ||
return false; | ||
} | ||
this.rules.remove(rule); | ||
@@ -1354,3 +1360,3 @@ | ||
for (var i = 0; i < this.registry.onProcessStyle.length; i++) { | ||
// $FlowFixMe | ||
// $FlowFixMe[prop-missing] | ||
rule.style = this.registry.onProcessStyle[i](rule.style, rule, sheet); | ||
@@ -1533,3 +1539,3 @@ } | ||
var sheets = new SheetsRegistry(); | ||
var registry = new SheetsRegistry(); | ||
/* eslint-disable */ | ||
@@ -1604,3 +1610,3 @@ // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 | ||
function getPropertyValue(cssRule, prop) { | ||
var getPropertyValue = function getPropertyValue(cssRule, prop) { | ||
try { | ||
@@ -1617,3 +1623,3 @@ // Support CSSTOM. | ||
} | ||
} | ||
}; | ||
/** | ||
@@ -1624,3 +1630,3 @@ * Set a style property. | ||
function setProperty(cssRule, prop, value) { | ||
var setProperty = function setProperty(cssRule, prop, value) { | ||
try { | ||
@@ -1650,3 +1656,3 @@ var cssValue = value; | ||
return true; | ||
} | ||
}; | ||
/** | ||
@@ -1657,3 +1663,3 @@ * Remove a style property. | ||
function removeProperty(cssRule, prop) { | ||
var removeProperty = function removeProperty(cssRule, prop) { | ||
try { | ||
@@ -1669,3 +1675,3 @@ // Support CSSTOM. | ||
} | ||
} | ||
}; | ||
/** | ||
@@ -1676,3 +1682,3 @@ * Set the selector. | ||
function setSelector(cssRule, selectorText) { | ||
var setSelector = function setSelector(cssRule, selectorText) { | ||
cssRule.selectorText = selectorText; // Return false if setter was not successful. | ||
@@ -1682,3 +1688,3 @@ // Currently works in chrome only. | ||
return cssRule.selectorText === selectorText; | ||
} | ||
}; | ||
/** | ||
@@ -1748,7 +1754,7 @@ * Gets the `head` element upon the first call and caches it. | ||
function findPrevNode(options) { | ||
var registry = sheets.registry; | ||
var registry$1 = registry.registry; | ||
if (registry.length > 0) { | ||
if (registry$1.length > 0) { | ||
// Try to insert before the next higher sheet. | ||
var sheet = findHigherSheet(registry, options); | ||
var sheet = findHigherSheet(registry$1, options); | ||
@@ -1763,3 +1769,3 @@ if (sheet && sheet.renderer) { | ||
sheet = findHighestSheet(registry, options); | ||
sheet = findHighestSheet(registry$1, options); | ||
@@ -1830,9 +1836,2 @@ if (sheet && sheet.renderer) { | ||
var _insertRule = function insertRule(container, rule, index) { | ||
var maxIndex = container.cssRules.length; // In case previous insertion fails, passed index might be wrong | ||
if (index === undefined || index > maxIndex) { | ||
// eslint-disable-next-line no-param-reassign | ||
index = maxIndex; | ||
} | ||
try { | ||
@@ -1856,2 +1855,13 @@ if ('insertRule' in container) { | ||
var getValidRuleInsertionIndex = function getValidRuleInsertionIndex(container, index) { | ||
var maxIndex = container.cssRules.length; // In case previous insertion fails, passed index might be wrong | ||
if (index === undefined || index > maxIndex) { | ||
// eslint-disable-next-line no-param-reassign | ||
return maxIndex; | ||
} | ||
return index; | ||
}; | ||
var createStyle = function createStyle() { | ||
@@ -1870,2 +1880,4 @@ var el = document.createElement('style'); // Without it, IE will have a broken source order specificity if we | ||
// HTMLStyleElement needs fixing https://github.com/facebook/flow/issues/2696 | ||
// Will be empty if link: true option is not set, because | ||
// it is only for use together with insertRule API. | ||
function DomRenderer(sheet) { | ||
@@ -1878,5 +1890,6 @@ this.getPropertyValue = getPropertyValue; | ||
this.sheet = void 0; | ||
this.hasInsertedRules = false; // There is no sheet when the renderer is used from a standalone StyleRule. | ||
this.hasInsertedRules = false; | ||
this.cssRules = []; // There is no sheet when the renderer is used from a standalone StyleRule. | ||
if (sheet) sheets.add(sheet); | ||
if (sheet) registry.add(sheet); | ||
this.sheet = sheet; | ||
@@ -1922,4 +1935,11 @@ | ||
_proto.detach = function detach() { | ||
if (!this.sheet) return; | ||
var parentNode = this.element.parentNode; | ||
if (parentNode) parentNode.removeChild(this.element); | ||
if (parentNode) parentNode.removeChild(this.element); // In the most browsers, rules inserted using insertRule() API will be lost when style element is removed. | ||
// Though IE will keep them and we need a consistent behavior. | ||
if (this.sheet.options.link) { | ||
this.cssRules = []; | ||
this.element.textContent = '\n'; | ||
} | ||
} | ||
@@ -1967,6 +1987,8 @@ /** | ||
if (rule.type === 'conditional' || rule.type === 'keyframes') { | ||
// We need to render the container without children first. | ||
var _insertionIndex = getValidRuleInsertionIndex(nativeParent, index); // We need to render the container without children first. | ||
latestNativeParent = _insertRule(nativeParent, parent.toString({ | ||
children: false | ||
}), index); | ||
}), _insertionIndex); | ||
@@ -1976,2 +1998,4 @@ if (latestNativeParent === false) { | ||
} | ||
this.refCssRule(rule, _insertionIndex, latestNativeParent); | ||
} | ||
@@ -1981,9 +2005,2 @@ | ||
return latestNativeParent; | ||
} // IE keeps the CSSStyleSheet after style node has been reattached, | ||
// so we need to check if the `renderable` reference the right style sheet and not | ||
// rerender those rules. | ||
if (rule.renderable && rule.renderable.parentStyleSheet === this.element.sheet) { | ||
return rule.renderable; | ||
} | ||
@@ -1993,4 +2010,5 @@ | ||
if (!ruleStr) return false; | ||
var insertionIndex = getValidRuleInsertionIndex(nativeParent, index); | ||
var nativeRule = _insertRule(nativeParent, ruleStr, index); | ||
var nativeRule = _insertRule(nativeParent, ruleStr, insertionIndex); | ||
@@ -2002,4 +2020,13 @@ if (nativeRule === false) { | ||
this.hasInsertedRules = true; | ||
rule.renderable = nativeRule; | ||
this.refCssRule(rule, insertionIndex, nativeRule); | ||
return nativeRule; | ||
}; | ||
_proto.refCssRule = function refCssRule(rule, index, cssRule) { | ||
rule.renderable = cssRule; // We only want to reference the top level rules, deleteRule API doesn't support removing nested rules | ||
// like rules inside media queries or keyframes | ||
if (rule.options.parent instanceof StyleSheet) { | ||
this.cssRules[index] = cssRule; | ||
} | ||
} | ||
@@ -2016,2 +2043,3 @@ /** | ||
sheet.deleteRule(index); | ||
this.cssRules.splice(index, 1); | ||
return true; | ||
@@ -2025,9 +2053,3 @@ } | ||
_proto.indexOf = function indexOf(cssRule) { | ||
var cssRules = this.element.sheet.cssRules; | ||
for (var index = 0; index < cssRules.length; index++) { | ||
if (cssRule === cssRules[index]) return index; | ||
} | ||
return -1; | ||
return this.cssRules.indexOf(cssRule); | ||
} | ||
@@ -2045,2 +2067,3 @@ /** | ||
this.element.sheet.deleteRule(index); | ||
this.cssRules.splice(index, 1); | ||
return this.insertRule(rule, index); | ||
@@ -2067,3 +2090,3 @@ } | ||
this.id = instanceCounter++; | ||
this.version = "10.4.0"; | ||
this.version = "10.5.0"; | ||
this.plugins = new PluginsRegistry(); | ||
@@ -2140,3 +2163,3 @@ this.options = { | ||
if (typeof index !== 'number') { | ||
index = sheets.index === 0 ? 0 : sheets.index + 1; | ||
index = registry.index === 0 ? 0 : registry.index + 1; | ||
} | ||
@@ -2161,3 +2184,3 @@ | ||
sheet.detach(); | ||
sheets.remove(sheet); | ||
registry.remove(sheet); | ||
return this; | ||
@@ -2182,5 +2205,5 @@ } | ||
if (typeof name === 'object') { | ||
// $FlowIgnore | ||
// $FlowFixMe[incompatible-call] | ||
return this.createRule(undefined, name, style); | ||
} // $FlowIgnore | ||
} // $FlowFixMe[incompatible-type] | ||
@@ -2233,3 +2256,3 @@ | ||
var index = create(); | ||
var jss = create(); | ||
@@ -2278,3 +2301,3 @@ var at = '@global'; | ||
var rule = this.rules.add(name, style, options); | ||
this.options.jss.plugins.onProcessRule(rule); | ||
if (rule) this.options.jss.plugins.onProcessRule(rule); | ||
return rule; | ||
@@ -2343,3 +2366,3 @@ } | ||
function handleNestedGlobalContainerRule(rule) { | ||
function handleNestedGlobalContainerRule(rule, sheet) { | ||
var options = rule.options, | ||
@@ -2351,3 +2374,3 @@ style = rule.style; | ||
for (var name in rules) { | ||
options.sheet.addRule(name, rules[name], _extends({}, options, { | ||
sheet.addRule(name, rules[name], _extends({}, options, { | ||
selector: addScope(name, rule.selector) | ||
@@ -2360,3 +2383,3 @@ })); | ||
function handlePrefixedGlobalRule(rule) { | ||
function handlePrefixedGlobalRule(rule, sheet) { | ||
var options = rule.options, | ||
@@ -2368,3 +2391,3 @@ style = rule.style; | ||
var selector = addScope(prop.substr(at.length), rule.selector); | ||
options.sheet.addRule(selector, style[prop], _extends({}, options, { | ||
sheet.addRule(selector, style[prop], _extends({}, options, { | ||
selector: selector | ||
@@ -2410,6 +2433,6 @@ })); | ||
function onProcessRule(rule) { | ||
if (rule.type !== 'style') return; | ||
handleNestedGlobalContainerRule(rule); | ||
handlePrefixedGlobalRule(rule); | ||
function onProcessRule(rule, sheet) { | ||
if (rule.type !== 'style' || !sheet) return; | ||
handleNestedGlobalContainerRule(rule, sheet); | ||
handlePrefixedGlobalRule(rule, sheet); | ||
} | ||
@@ -2416,0 +2439,0 @@ |
@@ -5,7 +5,9 @@ 'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var _extends = _interopDefault(require('@babel/runtime/helpers/extends')); | ||
var _extends = require('@babel/runtime/helpers/extends'); | ||
var jss = require('jss'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends); | ||
var at = '@global'; | ||
@@ -26,3 +28,3 @@ var atPrefix = '@global '; | ||
this.options = options; | ||
this.rules = new jss.RuleList(_extends({}, options, { | ||
this.rules = new jss.RuleList(_extends__default['default']({}, options, { | ||
parent: this | ||
@@ -54,3 +56,3 @@ })); | ||
var rule = this.rules.add(name, style, options); | ||
this.options.jss.plugins.onProcessRule(rule); | ||
if (rule) this.options.jss.plugins.onProcessRule(rule); | ||
return rule; | ||
@@ -91,3 +93,3 @@ } | ||
var selector = key.substr(atPrefix.length); | ||
this.rule = options.jss.createRule(selector, style, _extends({}, options, { | ||
this.rule = options.jss.createRule(selector, style, _extends__default['default']({}, options, { | ||
parent: this | ||
@@ -120,3 +122,3 @@ })); | ||
function handleNestedGlobalContainerRule(rule) { | ||
function handleNestedGlobalContainerRule(rule, sheet) { | ||
var options = rule.options, | ||
@@ -128,3 +130,3 @@ style = rule.style; | ||
for (var name in rules) { | ||
options.sheet.addRule(name, rules[name], _extends({}, options, { | ||
sheet.addRule(name, rules[name], _extends__default['default']({}, options, { | ||
selector: addScope(name, rule.selector) | ||
@@ -137,3 +139,3 @@ })); | ||
function handlePrefixedGlobalRule(rule) { | ||
function handlePrefixedGlobalRule(rule, sheet) { | ||
var options = rule.options, | ||
@@ -145,3 +147,3 @@ style = rule.style; | ||
var selector = addScope(prop.substr(at.length), rule.selector); | ||
options.sheet.addRule(selector, style[prop], _extends({}, options, { | ||
sheet.addRule(selector, style[prop], _extends__default['default']({}, options, { | ||
selector: selector | ||
@@ -187,6 +189,6 @@ })); | ||
function onProcessRule(rule) { | ||
if (rule.type !== 'style') return; | ||
handleNestedGlobalContainerRule(rule); | ||
handlePrefixedGlobalRule(rule); | ||
function onProcessRule(rule, sheet) { | ||
if (rule.type !== 'style' || !sheet) return; | ||
handleNestedGlobalContainerRule(rule, sheet); | ||
handlePrefixedGlobalRule(rule, sheet); | ||
} | ||
@@ -193,0 +195,0 @@ |
@@ -46,3 +46,3 @@ import _extends from '@babel/runtime/helpers/esm/extends'; | ||
var rule = this.rules.add(name, style, options); | ||
this.options.jss.plugins.onProcessRule(rule); | ||
if (rule) this.options.jss.plugins.onProcessRule(rule); | ||
return rule; | ||
@@ -111,3 +111,3 @@ } | ||
function handleNestedGlobalContainerRule(rule) { | ||
function handleNestedGlobalContainerRule(rule, sheet) { | ||
var options = rule.options, | ||
@@ -119,3 +119,3 @@ style = rule.style; | ||
for (var name in rules) { | ||
options.sheet.addRule(name, rules[name], _extends({}, options, { | ||
sheet.addRule(name, rules[name], _extends({}, options, { | ||
selector: addScope(name, rule.selector) | ||
@@ -128,3 +128,3 @@ })); | ||
function handlePrefixedGlobalRule(rule) { | ||
function handlePrefixedGlobalRule(rule, sheet) { | ||
var options = rule.options, | ||
@@ -136,3 +136,3 @@ style = rule.style; | ||
var selector = addScope(prop.substr(at.length), rule.selector); | ||
options.sheet.addRule(selector, style[prop], _extends({}, options, { | ||
sheet.addRule(selector, style[prop], _extends({}, options, { | ||
selector: selector | ||
@@ -178,6 +178,6 @@ })); | ||
function onProcessRule(rule) { | ||
if (rule.type !== 'style') return; | ||
handleNestedGlobalContainerRule(rule); | ||
handlePrefixedGlobalRule(rule); | ||
function onProcessRule(rule, sheet) { | ||
if (rule.type !== 'style' || !sheet) return; | ||
handleNestedGlobalContainerRule(rule, sheet); | ||
handlePrefixedGlobalRule(rule, sheet); | ||
} | ||
@@ -184,0 +184,0 @@ |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('jss')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'jss'], factory) : | ||
(global = global || self, factory(global.jssPluginGlobal = {}, global.jss)); | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.jssPluginGlobal = {}, global.jss)); | ||
}(this, (function (exports, jss) { 'use strict'; | ||
@@ -67,3 +67,3 @@ | ||
var rule = this.rules.add(name, style, options); | ||
this.options.jss.plugins.onProcessRule(rule); | ||
if (rule) this.options.jss.plugins.onProcessRule(rule); | ||
return rule; | ||
@@ -132,3 +132,3 @@ } | ||
function handleNestedGlobalContainerRule(rule) { | ||
function handleNestedGlobalContainerRule(rule, sheet) { | ||
var options = rule.options, | ||
@@ -140,3 +140,3 @@ style = rule.style; | ||
for (var name in rules) { | ||
options.sheet.addRule(name, rules[name], _extends({}, options, { | ||
sheet.addRule(name, rules[name], _extends({}, options, { | ||
selector: addScope(name, rule.selector) | ||
@@ -149,3 +149,3 @@ })); | ||
function handlePrefixedGlobalRule(rule) { | ||
function handlePrefixedGlobalRule(rule, sheet) { | ||
var options = rule.options, | ||
@@ -157,3 +157,3 @@ style = rule.style; | ||
var selector = addScope(prop.substr(at.length), rule.selector); | ||
options.sheet.addRule(selector, style[prop], _extends({}, options, { | ||
sheet.addRule(selector, style[prop], _extends({}, options, { | ||
selector: selector | ||
@@ -199,6 +199,6 @@ })); | ||
function onProcessRule(rule) { | ||
if (rule.type !== 'style') return; | ||
handleNestedGlobalContainerRule(rule); | ||
handlePrefixedGlobalRule(rule); | ||
function onProcessRule(rule, sheet) { | ||
if (rule.type !== 'style' || !sheet) return; | ||
handleNestedGlobalContainerRule(rule, sheet); | ||
handlePrefixedGlobalRule(rule, sheet); | ||
} | ||
@@ -205,0 +205,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("jss")):"function"==typeof define&&define.amd?define(["exports","jss"],e):e((t=t||self).jssPluginGlobal={},t.jss)}(this,function(t,e){"use strict";function s(){return(s=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(t[n]=s[n])}return t}).apply(this,arguments)}var n="@global",r="@global ",i=function(){function t(t,r,i){for(var o in this.type="global",this.at=n,this.rules=void 0,this.options=void 0,this.key=void 0,this.isProcessed=!1,this.key=t,this.options=i,this.rules=new e.RuleList(s({},i,{parent:this})),r)this.rules.add(o,r[o]);this.rules.process()}var r=t.prototype;return r.getRule=function(t){return this.rules.get(t)},r.addRule=function(t,e,s){var n=this.rules.add(t,e,s);return this.options.jss.plugins.onProcessRule(n),n},r.indexOf=function(t){return this.rules.indexOf(t)},r.toString=function(){return this.rules.toString()},t}(),o=function(){function t(t,e,i){this.type="global",this.at=n,this.options=void 0,this.rule=void 0,this.isProcessed=!1,this.key=void 0,this.key=t,this.options=i;var o=t.substr(r.length);this.rule=i.jss.createRule(o,e,s({},i,{parent:this}))}return t.prototype.toString=function(t){return this.rule?this.rule.toString(t):""},t}(),u=/\s*,\s*/g;function l(t,e){for(var s=t.split(u),n="",r=0;r<s.length;r++)n+=e+" "+s[r].trim(),s[r+1]&&(n+=", ");return n}t.default=function(){return{onCreateRule:function(t,e,s){if(!t)return null;if(t===n)return new i(t,e,s);if("@"===t[0]&&t.substr(0,r.length)===r)return new o(t,e,s);var u=s.parent;return u&&("global"===u.type||u.options.parent&&"global"===u.options.parent.type)&&(s.scoped=!1),!1===s.scoped&&(s.selector=t),null},onProcessRule:function(t){"style"===t.type&&(function(t){var e=t.options,r=t.style,i=r?r[n]:null;if(i){for(var o in i)e.sheet.addRule(o,i[o],s({},e,{selector:l(o,t.selector)}));delete r[n]}}(t),function(t){var e=t.options,r=t.style;for(var i in r)if("@"===i[0]&&i.substr(0,n.length)===n){var o=l(i.substr(n.length),t.selector);e.sheet.addRule(o,r[i],s({},e,{selector:o})),delete r[i]}}(t))}}},Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("jss")):"function"==typeof define&&define.amd?define(["exports","jss"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).jssPluginGlobal={},t.jss)}(this,(function(t,e){"use strict";function s(){return(s=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(t[n]=s[n])}return t}).apply(this,arguments)}var n="@global",r="@global ",i=function(){function t(t,r,i){for(var o in this.type="global",this.at=n,this.rules=void 0,this.options=void 0,this.key=void 0,this.isProcessed=!1,this.key=t,this.options=i,this.rules=new e.RuleList(s({},i,{parent:this})),r)this.rules.add(o,r[o]);this.rules.process()}var r=t.prototype;return r.getRule=function(t){return this.rules.get(t)},r.addRule=function(t,e,s){var n=this.rules.add(t,e,s);return n&&this.options.jss.plugins.onProcessRule(n),n},r.indexOf=function(t){return this.rules.indexOf(t)},r.toString=function(){return this.rules.toString()},t}(),o=function(){function t(t,e,i){this.type="global",this.at=n,this.options=void 0,this.rule=void 0,this.isProcessed=!1,this.key=void 0,this.key=t,this.options=i;var o=t.substr(r.length);this.rule=i.jss.createRule(o,e,s({},i,{parent:this}))}return t.prototype.toString=function(t){return this.rule?this.rule.toString(t):""},t}(),u=/\s*,\s*/g;function l(t,e){for(var s=t.split(u),n="",r=0;r<s.length;r++)n+=e+" "+s[r].trim(),s[r+1]&&(n+=", ");return n}t.default=function(){return{onCreateRule:function(t,e,s){if(!t)return null;if(t===n)return new i(t,e,s);if("@"===t[0]&&t.substr(0,r.length)===r)return new o(t,e,s);var u=s.parent;return u&&("global"===u.type||u.options.parent&&"global"===u.options.parent.type)&&(s.scoped=!1),!1===s.scoped&&(s.selector=t),null},onProcessRule:function(t,e){"style"===t.type&&e&&(function(t,e){var r=t.options,i=t.style,o=i?i[n]:null;if(o){for(var u in o)e.addRule(u,o[u],s({},r,{selector:l(u,t.selector)}));delete i[n]}}(t,e),function(t,e){var r=t.options,i=t.style;for(var o in i)if("@"===o[0]&&o.substr(0,n.length)===n){var u=l(o.substr(n.length),t.selector);e.addRule(u,i[o],s({},r,{selector:u})),delete i[o]}}(t,e))}}},Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "jss-plugin-global", | ||
"description": "Global styles for JSS", | ||
"version": "10.4.0", | ||
"version": "10.5.0", | ||
"license": "MIT", | ||
@@ -22,3 +22,3 @@ "homepage": "https://cssinjs.org/jss-global", | ||
"src", | ||
"LICENSE" | ||
"!*.test.*" | ||
], | ||
@@ -39,9 +39,9 @@ "keywords": [ | ||
"devDependencies": { | ||
"jss-plugin-nested": "10.4.0" | ||
"jss-plugin-nested": "10.5.0" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.3.1", | ||
"jss": "10.4.0" | ||
"jss": "10.5.0" | ||
}, | ||
"gitHead": "a864fcf08c6da3cbb7ae878c09eaf52e619ed6c3" | ||
"gitHead": "f9d93723ea0b8748c8a89248ebb680ed07e95c48" | ||
} |
@@ -12,3 +12,3 @@ # jss-plugin-global | ||
See our website [jss-plugin-global](https://cssinjs.org/jss-plugin-global?v=v10.4.0) for more information. | ||
See our website [jss-plugin-global](https://cssinjs.org/jss-plugin-global?v=v10.5.0) for more information. | ||
@@ -15,0 +15,0 @@ ## Install |
@@ -54,3 +54,3 @@ // @flow | ||
const rule = this.rules.add(name, style, options) | ||
this.options.jss.plugins.onProcessRule(rule) | ||
if (rule) this.options.jss.plugins.onProcessRule(rule) | ||
return rule | ||
@@ -114,3 +114,3 @@ } | ||
function handleNestedGlobalContainerRule(rule) { | ||
function handleNestedGlobalContainerRule(rule, sheet) { | ||
const {options, style} = rule | ||
@@ -122,3 +122,3 @@ const rules = style ? style[at] : null | ||
for (const name in rules) { | ||
options.sheet.addRule(name, rules[name], { | ||
sheet.addRule(name, rules[name], { | ||
...options, | ||
@@ -132,3 +132,3 @@ selector: addScope(name, rule.selector) | ||
function handlePrefixedGlobalRule(rule) { | ||
function handlePrefixedGlobalRule(rule, sheet) { | ||
const {options, style} = rule | ||
@@ -139,3 +139,3 @@ for (const prop in style) { | ||
const selector = addScope(prop.substr(at.length), rule.selector) | ||
options.sheet.addRule(selector, style[prop], { | ||
sheet.addRule(selector, style[prop], { | ||
...options, | ||
@@ -184,7 +184,7 @@ selector | ||
function onProcessRule(rule) { | ||
if (rule.type !== 'style') return | ||
function onProcessRule(rule, sheet) { | ||
if (rule.type !== 'style' || !sheet) return | ||
handleNestedGlobalContainerRule(((rule: any): StyleRule)) | ||
handlePrefixedGlobalRule(((rule: any): StyleRule)) | ||
handleNestedGlobalContainerRule(((rule: any): StyleRule), sheet) | ||
handlePrefixedGlobalRule(((rule: any): StyleRule), sheet) | ||
} | ||
@@ -191,0 +191,0 @@ |
Sorry, the diff of this file is not supported yet
93193
12
2587
+ Addedindefinite-observable@2.0.1(transitive)
+ Addedjss@10.5.0(transitive)
+ Addedsymbol-observable@1.2.0(transitive)
- Removedjss@10.4.0(transitive)
Updatedjss@10.5.0