jss-plugin-nested
Advanced tools
Comparing version 10.0.0-alpha.3 to 10.0.0-alpha.4
@@ -19,51 +19,20 @@ function _extends() { | ||
/** | ||
* Copyright 2014-2015, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
var warning = function warning() {}; | ||
{ | ||
warning = function warning(condition, format, args) { | ||
var len = arguments.length; | ||
args = new Array(len > 2 ? len - 2 : 0); | ||
for (var key = 2; key < len; key++) { | ||
args[key - 2] = arguments[key]; | ||
function warning(condition, message) { | ||
{ | ||
if (condition) { | ||
return; | ||
} | ||
if (format === undefined) { | ||
throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); | ||
} | ||
var text = "Warning: " + message; | ||
if (format.length < 10 || /^[s\W]*$/.test(format)) { | ||
throw new Error('The warning format should be able to uniquely identify this ' + 'warning. Please, use a more descriptive format than: ' + format); | ||
if (typeof console !== 'undefined') { | ||
console.warn(text); | ||
} | ||
if (!condition) { | ||
var argIndex = 0; | ||
var message = 'Warning: ' + format.replace(/%s/g, function () { | ||
return args[argIndex++]; | ||
}); | ||
if (typeof console !== 'undefined') { | ||
console.error(message); | ||
} | ||
try { | ||
// This error was thrown as a convenience so that you can use this stack | ||
// to find the callsite that caused this warning to fire. | ||
throw new Error(message); | ||
} catch (x) {} | ||
} | ||
}; | ||
try { | ||
throw Error(text); | ||
} catch (x) {} | ||
} | ||
} | ||
var warning_1 = warning; | ||
var separatorRegExp = /\s*,\s*/g; | ||
@@ -90,3 +59,3 @@ var parentRegExp = /&/g; | ||
warning_1(false, '[JSS] Could not find the referenced rule %s in %s.', key, container.options.meta || container); | ||
warning(false, "[JSS] Could not find the referenced rule " + key + " in " + (container.options.meta || container.toString()) + "."); | ||
return key; | ||
@@ -93,0 +62,0 @@ }; |
@@ -8,3 +8,3 @@ 'use strict'; | ||
var _extends = _interopDefault(require('@babel/runtime/helpers/extends')); | ||
var warning = _interopDefault(require('warning')); | ||
var warning = _interopDefault(require('tiny-warning')); | ||
@@ -32,3 +32,3 @@ var separatorRegExp = /\s*,\s*/g; | ||
warning(false, '[JSS] Could not find the referenced rule %s in %s.', key, container.options.meta || container); | ||
warning(false, "[JSS] Could not find the referenced rule " + key + " in " + (container.options.meta || container.toString()) + "."); | ||
return key; | ||
@@ -35,0 +35,0 @@ }; |
import _extends from '@babel/runtime/helpers/esm/extends'; | ||
import warning from 'warning'; | ||
import warning from 'tiny-warning'; | ||
@@ -25,3 +25,3 @@ var separatorRegExp = /\s*,\s*/g; | ||
warning(false, '[JSS] Could not find the referenced rule %s in %s.', key, container.options.meta || container); | ||
warning(false, "[JSS] Could not find the referenced rule " + key + " in " + (container.options.meta || container.toString()) + "."); | ||
return key; | ||
@@ -28,0 +28,0 @@ }; |
@@ -25,51 +25,20 @@ (function (global, factory) { | ||
/** | ||
* Copyright 2014-2015, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
var warning = function warning() {}; | ||
{ | ||
warning = function warning(condition, format, args) { | ||
var len = arguments.length; | ||
args = new Array(len > 2 ? len - 2 : 0); | ||
for (var key = 2; key < len; key++) { | ||
args[key - 2] = arguments[key]; | ||
function warning(condition, message) { | ||
{ | ||
if (condition) { | ||
return; | ||
} | ||
if (format === undefined) { | ||
throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); | ||
} | ||
var text = "Warning: " + message; | ||
if (format.length < 10 || /^[s\W]*$/.test(format)) { | ||
throw new Error('The warning format should be able to uniquely identify this ' + 'warning. Please, use a more descriptive format than: ' + format); | ||
if (typeof console !== 'undefined') { | ||
console.warn(text); | ||
} | ||
if (!condition) { | ||
var argIndex = 0; | ||
var message = 'Warning: ' + format.replace(/%s/g, function () { | ||
return args[argIndex++]; | ||
}); | ||
if (typeof console !== 'undefined') { | ||
console.error(message); | ||
} | ||
try { | ||
// This error was thrown as a convenience so that you can use this stack | ||
// to find the callsite that caused this warning to fire. | ||
throw new Error(message); | ||
} catch (x) {} | ||
} | ||
}; | ||
try { | ||
throw Error(text); | ||
} catch (x) {} | ||
} | ||
} | ||
var warning_1 = warning; | ||
var separatorRegExp = /\s*,\s*/g; | ||
@@ -96,3 +65,3 @@ var parentRegExp = /&/g; | ||
warning_1(false, '[JSS] Could not find the referenced rule %s in %s.', key, container.options.meta || container); | ||
warning(false, "[JSS] Could not find the referenced rule " + key + " in " + (container.options.meta || container.toString()) + "."); | ||
return key; | ||
@@ -99,0 +68,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.jssPluginNested={})}(this,function(e){"use strict";function v(){return(v=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}var i=function(){},l=/\s*,\s*/g,d=/&/g,g=/\$([\w-]+)/g;e.default=function(){function a(r,o){return function(e,n){var t=r.getRule(n)||o&&o.getRule(n);return t?(t=t).selector:(i(!1,"[JSS] Could not find the referenced rule %s in %s.",n,r.options.meta||r),n)}}function c(e,n){for(var t=n.split(l),r=e.split(l),o="",i=0;i<t.length;i++)for(var u=t[i],f=0;f<r.length;f++){var s=r[f];o&&(o+=", "),o+=-1!==s.indexOf("&")?s.replace(d,u):u+" "+s}return o}function p(e,n,t){if(t)return v({},t,{index:t.index+1});var r=e.options.nestingLevel;return r=void 0===r?1:r+1,v({},e.options,{nestingLevel:r,index:n.indexOf(e)+1})}return{onProcessStyle:function(e,n,t){if("style"!==n.type)return e;var r,o,i=n,u=i.options.parent;for(var f in e){var s=-1!==f.indexOf("&"),l="@"===f[0];if(s||l){if(r=p(i,u,r),s){var d=c(f,i.selector);o||(o=a(u,t)),d=d.replace(g,o),u.addRule(d,e[f],v({},r,{selector:d}))}else l&&u.addRule(f,{},r).addRule(i.key,e[f],{selector:i.selector});delete e[f]}}return e}}},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.jssPluginNested={})}(this,function(e){"use strict";function v(){return(v=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var l=/\s*,\s*/g,a=/&/g,g=/\$([\w-]+)/g;e.default=function(){function c(r,o){return function(e,t){var n=r.getRule(t)||o&&o.getRule(t);return n?(n=n).selector:(r.options.meta||r.toString(),t)}}function d(e,t){for(var n=t.split(l),r=e.split(l),o="",i=0;i<n.length;i++)for(var s=n[i],u=0;u<r.length;u++){var f=r[u];o&&(o+=", "),o+=-1!==f.indexOf("&")?f.replace(a,s):s+" "+f}return o}function p(e,t,n){if(n)return v({},n,{index:n.index+1});var r=e.options.nestingLevel;return r=void 0===r?1:r+1,v({},e.options,{nestingLevel:r,index:t.indexOf(e)+1})}return{onProcessStyle:function(e,t,n){if("style"!==t.type)return e;var r,o,i=t,s=i.options.parent;for(var u in e){var f=-1!==u.indexOf("&"),l="@"===u[0];if(f||l){if(r=p(i,s,r),f){var a=d(u,i.selector);o||(o=c(s,n)),a=a.replace(g,o),s.addRule(a,e[u],v({},r,{selector:a}))}else l&&s.addRule(u,{},r).addRule(i.key,e[u],{selector:i.selector});delete e[u]}}return e}}},Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "jss-plugin-nested", | ||
"description": "JSS plugin that enables support for nested selectors", | ||
"version": "10.0.0-alpha.3", | ||
"version": "10.0.0-alpha.4", | ||
"license": "MIT", | ||
@@ -37,16 +37,17 @@ "homepage": "https://cssinjs.org/jss-nested", | ||
"scripts": { | ||
"build": "node ../../scripts/build.js", | ||
"prepare": "node ../../scripts/build.js", | ||
"check-snapshot": "node ../../scripts/match-snapshot.js" | ||
}, | ||
"devDependencies": { | ||
"jss": "^10.0.0-alpha.3", | ||
"jss-plugin-rule-value-function": "^10.0.0-alpha.3" | ||
"jss": "^10.0.0-alpha.4", | ||
"jss-plugin-rule-value-function": "^10.0.0-alpha.4" | ||
}, | ||
"peerDependencies": { | ||
"jss": "^9.0.0" | ||
"jss": "^10.0.0-alpha.3" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.0.0", | ||
"warning": "^3.0.0" | ||
} | ||
"tiny-warning": "^1.0.2" | ||
}, | ||
"gitHead": "4efd47a4af45de9c8784d68f3a239f9a1d29c942" | ||
} |
// @flow | ||
import warning from 'warning' | ||
import warning from 'tiny-warning' | ||
import type {Plugin, StyleRule, StyleSheet} from 'jss' | ||
@@ -28,5 +28,4 @@ | ||
false, | ||
'[JSS] Could not find the referenced rule %s in %s.', | ||
key, | ||
container.options.meta || container | ||
`[JSS] Could not find the referenced rule ${key} in ${container.options.meta || | ||
container.toString()}.` | ||
) | ||
@@ -33,0 +32,0 @@ return key |
@@ -7,2 +7,3 @@ /* eslint-disable no-underscore-dangle */ | ||
import {create} from 'jss' | ||
import sinon from 'sinon' | ||
import functionPlugin from 'jss-plugin-rule-value-function' | ||
@@ -17,9 +18,6 @@ import nested from '.' | ||
let jss | ||
let warning | ||
let spy | ||
beforeEach(() => { | ||
nested.__Rewire__('warning', (condition, message) => { | ||
warning = message | ||
}) | ||
spy = sinon.spy(console, 'warn') | ||
jss = create(settings).use(nested()) | ||
@@ -29,4 +27,3 @@ }) | ||
afterEach(() => { | ||
nested.__ResetDependency__('warning') | ||
warning = undefined | ||
console.warn.restore() | ||
}) | ||
@@ -411,3 +408,8 @@ | ||
expect(warning).to.be('[JSS] Could not find the referenced rule %s in %s.') | ||
expect(spy.callCount).to.be(1) | ||
expect( | ||
spy.calledWithExactly( | ||
'Warning: [JSS] Could not find the referenced rule b in .a-id {\n & $b: [object Object];\n}.' | ||
) | ||
).to.be(true) | ||
}) | ||
@@ -414,0 +416,0 @@ }) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46598
1103
+ Addedtiny-warning@^1.0.2
+ Addedcsstype@3.1.3(transitive)
+ Addedjss@10.10.0(transitive)
+ Addedtiny-warning@1.0.3(transitive)
- Removedwarning@^3.0.0
- Removedjs-tokens@4.0.0(transitive)
- Removedjss@9.8.7(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedsymbol-observable@1.2.0(transitive)
- Removedwarning@3.0.0(transitive)