styled-components 2.1.1 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/CODE_OF_CONDUCT.md +1 -1
  3. package/README.md +12 -67
  4. package/dist/styled-components.es.js +273 -110
  5. package/dist/styled-components.js +325 -119
  6. package/dist/styled-components.min.js +2 -2
  7. package/lib/hoc/withTheme.js +13 -7
  8. package/lib/models/BrowserStyleSheet.js +11 -0
  9. package/lib/models/ComponentStyle.js +45 -2
  10. package/lib/models/InlineStyle.js +1 -1
  11. package/lib/models/ServerStyleSheet.js +33 -17
  12. package/lib/models/StyleSheet.js +9 -0
  13. package/lib/models/StyledComponent.js +82 -38
  14. package/lib/models/StyledNativeComponent.js +31 -15
  15. package/lib/models/ThemeProvider.js +44 -12
  16. package/lib/native/index.js +1 -1
  17. package/lib/test/utils.js +5 -2
  18. package/lib/utils/create-broadcast.js +34 -24
  19. package/lib/utils/domElements.js +1 -1
  20. package/lib/utils/flatten.js +4 -1
  21. package/lib/utils/generateAlphabeticName.js +1 -1
  22. package/lib/utils/nonce.js +10 -0
  23. package/lib/utils/once.js +17 -0
  24. package/package.json +10 -10
  25. package/src/hoc/withTheme.js +14 -7
  26. package/src/models/BrowserStyleSheet.js +8 -0
  27. package/src/models/ComponentStyle.js +42 -2
  28. package/src/models/InlineStyle.js +1 -1
  29. package/src/models/ServerStyleSheet.js +27 -12
  30. package/src/models/StyleSheet.js +9 -0
  31. package/src/models/StyledComponent.js +81 -26
  32. package/src/models/StyledNativeComponent.js +30 -10
  33. package/src/models/ThemeProvider.js +38 -9
  34. package/src/models/test/ThemeProvider.test.js +7 -8
  35. package/src/native/index.js +1 -1
  36. package/src/native/test/native.test.js +14 -0
  37. package/src/test/__snapshots__/ssr.test.js.snap +147 -0
  38. package/src/test/expanded-api.test.js +24 -0
  39. package/src/test/props.test.js +14 -3
  40. package/src/test/ssr.test.js +90 -123
  41. package/src/test/styles.test.js +52 -0
  42. package/src/test/utils.js +5 -2
  43. package/src/utils/create-broadcast.js +31 -17
  44. package/src/utils/domElements.js +1 -0
  45. package/src/utils/flatten.js +16 -6
  46. package/src/utils/generateAlphabeticName.js +1 -1
  47. package/src/utils/nonce.js +6 -0
  48. package/src/utils/once.js +12 -0
  49. package/typings/styled-components.d.ts +15 -21
  50. package/typings/tests/issue1068.tsx +226 -0
  51. package/typings/tests/main-test.tsx +1 -1
  52. package/typings/tests/string-tags-test.tsx +62 -0
  53. package/typings/tests/themed-tests/issue1068.tsx +226 -0
  54. package/typings/tests/themed-tests/mytheme-styled-components.tsx +1 -1
  55. package/typings/tests/themed-tests/with-theme-test.tsx +2 -1
  56. package/typings/tests/with-theme-test.tsx +17 -0
  57. package/lib/constructors/test/injectGlobal.test.js +0 -63
  58. package/lib/constructors/test/keyframes.test.js +0 -48
  59. package/lib/constructors/test/styled.test.js +0 -19
  60. package/lib/models/AbstractStyledComponent.js +0 -43
  61. package/lib/models/test/ThemeProvider.test.js +0 -200
  62. package/lib/native/test/native.test.js +0 -290
  63. package/lib/no-parser/test/basic.test.js +0 -46
  64. package/lib/no-parser/test/flatten.test.js +0 -125
  65. package/lib/no-parser/test/keyframes.test.js +0 -45
  66. package/lib/primitives/test/primitives.test.js +0 -289
  67. package/lib/test/attrs.test.js +0 -158
  68. package/lib/test/basic.test.js +0 -267
  69. package/lib/test/css.test.js +0 -43
  70. package/lib/test/expanded-api.test.js +0 -90
  71. package/lib/test/extending.test.js +0 -198
  72. package/lib/test/overriding.test.js +0 -35
  73. package/lib/test/props.test.js +0 -38
  74. package/lib/test/rehydration.test.js +0 -306
  75. package/lib/test/ssr.test.js +0 -187
  76. package/lib/test/styles.test.js +0 -146
  77. package/lib/test/theme.test.js +0 -497
  78. package/lib/test/warnTooManyClasses.test.js +0 -71
  79. package/lib/utils/test/extractCompsFromCSS.test.js +0 -46
  80. package/lib/utils/test/flatten.test.js +0 -109
  81. package/lib/utils/test/generateAlphabeticName.test.js +0 -14
  82. package/lib/utils/test/interleave.test.js +0 -22
  83. package/lib/utils/test/validAttr.test.js +0 -560
  84. package/src/models/AbstractStyledComponent.js +0 -21
  85. package/typings/tags.d.ts +0 -137
@@ -210,7 +210,10 @@ var index = function isPlainObject(o) {
210
210
 
211
211
  //
212
212
  var objToCss = function objToCss(obj, prevKey) {
213
- var css = Object.keys(obj).map(function (key) {
213
+ var css = Object.keys(obj).filter(function (key) {
214
+ var chunk = obj[key];
215
+ return chunk !== undefined && chunk !== null && chunk !== false && chunk !== '';
216
+ }).map(function (key) {
214
217
  if (index(obj[key])) return objToCss(obj[key], key);
215
218
  return hyphenateStyleName_1(key) + ': ' + obj[key] + ';';
216
219
  }).join(' ');
@@ -1798,7 +1801,7 @@ var generateAlphabeticName = function generateAlphabeticName(code) {
1798
1801
  var name = '';
1799
1802
  var x = void 0;
1800
1803
 
1801
- for (x = code; x > charsLength; x = Math.floor(x / chars.length)) {
1804
+ for (x = code; x > charsLength; x = Math.floor(x / charsLength)) {
1802
1805
  name = chars[x % charsLength] + name;
1803
1806
  }
1804
1807
 
@@ -1844,6 +1847,14 @@ var extractCompsFromCSS = (function (maybeCSS) {
1844
1847
  });
1845
1848
 
1846
1849
  //
1850
+ /* eslint-disable camelcase, no-undef */
1851
+
1852
+ var getNonce = (function () {
1853
+ return typeof __webpack_nonce__ !== 'undefined' ? __webpack_nonce__ : null;
1854
+ });
1855
+
1856
+ //
1857
+ /* eslint-disable no-underscore-dangle */
1847
1858
  /*
1848
1859
  * Browser Style Sheet with Rehydration
1849
1860
  *
@@ -1907,6 +1918,12 @@ var BrowserTag = function () {
1907
1918
  var existingNames = this.el.getAttribute(SC_ATTR);
1908
1919
  this.el.setAttribute(SC_ATTR, existingNames ? existingNames + ' ' + name : name);
1909
1920
  }
1921
+
1922
+ var nonce = getNonce();
1923
+
1924
+ if (nonce) {
1925
+ this.el.setAttribute('nonce', nonce);
1926
+ }
1910
1927
  };
1911
1928
 
1912
1929
  BrowserTag.prototype.toHTML = function toHTML() {
@@ -2010,6 +2027,7 @@ var StyleSheet = function () {
2010
2027
  classCallCheck(this, StyleSheet);
2011
2028
  this.hashes = {};
2012
2029
  this.deferredInjections = {};
2030
+ this.stylesCacheable = typeof document !== 'undefined';
2013
2031
 
2014
2032
  this.tagConstructor = tagConstructor;
2015
2033
  this.tags = tags;
@@ -2017,6 +2035,15 @@ var StyleSheet = function () {
2017
2035
  this.constructComponentTagMap();
2018
2036
  }
2019
2037
 
2038
+ // helper for `ComponentStyle` to know when it cache static styles.
2039
+ // staticly styled-component can not safely cache styles on the server
2040
+ // without all `ComponentStyle` instances saving a reference to the
2041
+ // the styleSheet instance they last rendered with,
2042
+ // or listening to creation / reset events. otherwise you might create
2043
+ // a component with one stylesheet and render it another api response
2044
+ // with another, losing styles on from your server-side render.
2045
+
2046
+
2020
2047
  StyleSheet.prototype.constructComponentTagMap = function constructComponentTagMap() {
2021
2048
  var _this = this;
2022
2049
 
@@ -2213,7 +2240,7 @@ var emptyFunction_1 = emptyFunction$1;
2213
2240
 
2214
2241
  var validateFormat = function validateFormat(format) {};
2215
2242
 
2216
- {
2243
+ if (process.env.NODE_ENV !== 'production') {
2217
2244
  validateFormat = function validateFormat(format) {
2218
2245
  if (format === undefined) {
2219
2246
  throw new Error('invariant requires an error message argument');
@@ -2255,7 +2282,7 @@ var emptyFunction$2 = emptyFunction_1;
2255
2282
 
2256
2283
  var warning$1 = emptyFunction$2;
2257
2284
 
2258
- {
2285
+ if (process.env.NODE_ENV !== 'production') {
2259
2286
  (function () {
2260
2287
  var printWarning = function printWarning(format) {
2261
2288
  for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
@@ -2312,7 +2339,7 @@ var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
2312
2339
 
2313
2340
  var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
2314
2341
 
2315
- {
2342
+ if (process.env.NODE_ENV !== 'production') {
2316
2343
  var invariant$2 = invariant_1;
2317
2344
  var warning$2 = warning_1;
2318
2345
  var ReactPropTypesSecret$2 = ReactPropTypesSecret_1;
@@ -2331,7 +2358,7 @@ var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
2331
2358
  * @private
2332
2359
  */
2333
2360
  function checkPropTypes$1(typeSpecs, values, location, componentName, getStack) {
2334
- {
2361
+ if (process.env.NODE_ENV !== 'production') {
2335
2362
  for (var typeSpecName in typeSpecs) {
2336
2363
  if (typeSpecs.hasOwnProperty(typeSpecName)) {
2337
2364
  var error;
@@ -2500,7 +2527,7 @@ var factoryWithTypeCheckers = function factoryWithTypeCheckers(isValidElement, t
2500
2527
  PropTypeError.prototype = Error.prototype;
2501
2528
 
2502
2529
  function createChainableTypeChecker(validate) {
2503
- {
2530
+ if (process.env.NODE_ENV !== 'production') {
2504
2531
  var manualPropTypeCallCache = {};
2505
2532
  var manualPropTypeWarningCount = 0;
2506
2533
  }
@@ -2512,7 +2539,7 @@ var factoryWithTypeCheckers = function factoryWithTypeCheckers(isValidElement, t
2512
2539
  if (throwOnDirectAccess) {
2513
2540
  // New behavior only for users of `prop-types` package
2514
2541
  invariant(false, 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use `PropTypes.checkPropTypes()` to call them. ' + 'Read more at http://fb.me/use-check-prop-types');
2515
- } else if ("development" !== 'production' && typeof console !== 'undefined') {
2542
+ } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
2516
2543
  // Old behavior for people using React.PropTypes
2517
2544
  var cacheKey = componentName + ':' + propName;
2518
2545
  if (!manualPropTypeCallCache[cacheKey] &&
@@ -2611,7 +2638,7 @@ var factoryWithTypeCheckers = function factoryWithTypeCheckers(isValidElement, t
2611
2638
 
2612
2639
  function createEnumTypeChecker(expectedValues) {
2613
2640
  if (!Array.isArray(expectedValues)) {
2614
- warning(false, 'Invalid argument supplied to oneOf, expected an instance of array.');
2641
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0;
2615
2642
  return emptyFunction.thatReturnsNull;
2616
2643
  }
2617
2644
 
@@ -2654,7 +2681,7 @@ var factoryWithTypeCheckers = function factoryWithTypeCheckers(isValidElement, t
2654
2681
 
2655
2682
  function createUnionTypeChecker(arrayOfTypeCheckers) {
2656
2683
  if (!Array.isArray(arrayOfTypeCheckers)) {
2657
- warning(false, 'Invalid argument supplied to oneOfType, expected an instance of array.');
2684
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
2658
2685
  return emptyFunction.thatReturnsNull;
2659
2686
  }
2660
2687
 
@@ -2815,6 +2842,45 @@ var factoryWithTypeCheckers = function factoryWithTypeCheckers(isValidElement, t
2815
2842
  return ReactPropTypes;
2816
2843
  };
2817
2844
 
2845
+ var emptyFunction$3 = emptyFunction_1;
2846
+ var invariant$3 = invariant_1;
2847
+
2848
+ var factoryWithThrowingShims = function factoryWithThrowingShims() {
2849
+ // Important!
2850
+ // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
2851
+ function shim() {
2852
+ invariant$3(false, 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use PropTypes.checkPropTypes() to call them. ' + 'Read more at http://fb.me/use-check-prop-types');
2853
+ }
2854
+ shim.isRequired = shim;
2855
+ function getShim() {
2856
+ return shim;
2857
+ }
2858
+ var ReactPropTypes = {
2859
+ array: shim,
2860
+ bool: shim,
2861
+ func: shim,
2862
+ number: shim,
2863
+ object: shim,
2864
+ string: shim,
2865
+ symbol: shim,
2866
+
2867
+ any: shim,
2868
+ arrayOf: getShim,
2869
+ element: shim,
2870
+ instanceOf: getShim,
2871
+ node: shim,
2872
+ objectOf: getShim,
2873
+ oneOf: getShim,
2874
+ oneOfType: getShim,
2875
+ shape: getShim
2876
+ };
2877
+
2878
+ ReactPropTypes.checkPropTypes = emptyFunction$3;
2879
+ ReactPropTypes.PropTypes = ReactPropTypes;
2880
+
2881
+ return ReactPropTypes;
2882
+ };
2883
+
2818
2884
  var index$3 = createCommonjsModule(function (module) {
2819
2885
  /**
2820
2886
  * Copyright 2013-present, Facebook, Inc.
@@ -2825,7 +2891,7 @@ var index$3 = createCommonjsModule(function (module) {
2825
2891
  * of patent rights can be found in the PATENTS file in the same directory.
2826
2892
  */
2827
2893
 
2828
- {
2894
+ if (process.env.NODE_ENV !== 'production') {
2829
2895
  var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element') || 0xeac7;
2830
2896
 
2831
2897
  var isValidElement = function isValidElement(object) {
@@ -2836,6 +2902,10 @@ var index$3 = createCommonjsModule(function (module) {
2836
2902
  // http://fb.me/prop-types-in-prod
2837
2903
  var throwOnDirectAccess = true;
2838
2904
  module.exports = factoryWithTypeCheckers(isValidElement, throwOnDirectAccess);
2905
+ } else {
2906
+ // By explicitly using `prop-types` you are opting into new production behavior.
2907
+ // http://fb.me/prop-types-in-prod
2908
+ module.exports = factoryWithThrowingShims();
2839
2909
  }
2840
2910
  });
2841
2911
 
@@ -2874,6 +2944,7 @@ StyleSheetManager.propTypes = {
2874
2944
  };
2875
2945
 
2876
2946
  //
2947
+ /* eslint-disable no-underscore-dangle */
2877
2948
  var ServerTag = function () {
2878
2949
  function ServerTag(isLocal) {
2879
2950
  classCallCheck(this, ServerTag);
@@ -2894,6 +2965,14 @@ var ServerTag = function () {
2894
2965
  this.size += 1;
2895
2966
  };
2896
2967
 
2968
+ ServerTag.prototype.concatenateCSS = function concatenateCSS() {
2969
+ var _this = this;
2970
+
2971
+ return Object.keys(this.components).reduce(function (styles, k) {
2972
+ return styles + _this.components[k].css;
2973
+ }, '');
2974
+ };
2975
+
2897
2976
  ServerTag.prototype.inject = function inject(componentId, css, name) {
2898
2977
  var comp = this.components[componentId];
2899
2978
 
@@ -2906,40 +2985,42 @@ var ServerTag = function () {
2906
2985
  };
2907
2986
 
2908
2987
  ServerTag.prototype.toHTML = function toHTML() {
2909
- var _this = this;
2988
+ var attrs = ['type="text/css"', SC_ATTR + '="' + this.names.join(' ') + '"', LOCAL_ATTR + '="' + (this.isLocal ? 'true' : 'false') + '"'];
2910
2989
 
2911
- var namesAttr = SC_ATTR + '="' + this.names.join(' ') + '"';
2912
- var localAttr = LOCAL_ATTR + '="' + (this.isLocal ? 'true' : 'false') + '"';
2913
- var css = Object.keys(this.components).map(function (key) {
2914
- return _this.components[key].css;
2915
- }).join('');
2990
+ var nonce = getNonce();
2991
+
2992
+ if (nonce) {
2993
+ attrs.push('nonce="' + nonce + '"');
2994
+ }
2916
2995
 
2917
- return '<style type="text/css" ' + namesAttr + ' ' + localAttr + '>\n' + css + '\n</style>';
2996
+ return '<style ' + attrs.join(' ') + '>' + this.concatenateCSS() + '</style>';
2918
2997
  };
2919
2998
 
2920
2999
  ServerTag.prototype.toReactElement = function toReactElement(key) {
2921
- var _attributes,
2922
- _this2 = this;
3000
+ var _attrs;
2923
3001
 
2924
- var attributes = (_attributes = {}, _attributes[SC_ATTR] = this.names.join(' '), _attributes[LOCAL_ATTR] = this.isLocal.toString(), _attributes);
2925
- var css = Object.keys(this.components).map(function (k) {
2926
- return _this2.components[k].css;
2927
- }).join('');
3002
+ var attrs = (_attrs = {}, _attrs[SC_ATTR] = this.names.join(' '), _attrs[LOCAL_ATTR] = this.isLocal.toString(), _attrs);
3003
+
3004
+ var nonce = getNonce();
3005
+
3006
+ if (nonce) {
3007
+ attrs.nonce = nonce;
3008
+ }
2928
3009
 
2929
3010
  return React__default.createElement('style', _extends({
2930
- key: key, type: 'text/css' }, attributes, {
2931
- dangerouslySetInnerHTML: { __html: css }
3011
+ key: key, type: 'text/css' }, attrs, {
3012
+ dangerouslySetInnerHTML: { __html: this.concatenateCSS() }
2932
3013
  }));
2933
3014
  };
2934
3015
 
2935
3016
  ServerTag.prototype.clone = function clone() {
2936
- var _this3 = this;
3017
+ var _this2 = this;
2937
3018
 
2938
3019
  var copy = new ServerTag(this.isLocal);
2939
3020
  copy.names = [].concat(this.names);
2940
3021
  copy.size = this.size;
2941
3022
  copy.components = Object.keys(this.components).reduce(function (acc, key) {
2942
- acc[key] = _extends({}, _this3.components[key]); // eslint-disable-line no-param-reassign
3023
+ acc[key] = _extends({}, _this2.components[key]); // eslint-disable-line no-param-reassign
2943
3024
  return acc;
2944
3025
  }, {});
2945
3026
 
@@ -3646,32 +3727,54 @@ function isFunction(fn) {
3646
3727
  * @see https://github.com/ReactTraining/react-broadcast
3647
3728
  */
3648
3729
 
3649
- var createBroadcast = function createBroadcast(initialValue) {
3650
- var listeners = [];
3651
- var currentValue = initialValue;
3730
+ var createBroadcast = function createBroadcast(initialState) {
3731
+ var listeners = {};
3732
+ var id = 0;
3733
+ var state = initialState;
3652
3734
 
3653
- return {
3654
- publish: function publish(value) {
3655
- currentValue = value;
3656
- listeners.forEach(function (listener) {
3657
- return listener(currentValue);
3658
- });
3659
- },
3660
- subscribe: function subscribe(listener) {
3661
- listeners.push(listener);
3735
+ function publish(nextState) {
3736
+ state = nextState;
3662
3737
 
3663
- // Publish to this subscriber once immediately.
3664
- listener(currentValue);
3738
+ // eslint-disable-next-line guard-for-in, no-restricted-syntax
3739
+ for (var key in listeners) {
3740
+ var listener = listeners[key];
3741
+ if (listener === undefined) {
3742
+ // eslint-disable-next-line no-continue
3743
+ continue;
3744
+ }
3665
3745
 
3666
- return function () {
3667
- listeners = listeners.filter(function (item) {
3668
- return item !== listener;
3669
- });
3670
- };
3746
+ listener(state);
3671
3747
  }
3672
- };
3748
+ }
3749
+
3750
+ function subscribe(listener) {
3751
+ var currentId = id;
3752
+ listeners[currentId] = listener;
3753
+ id += 1;
3754
+ listener(state);
3755
+ return currentId;
3756
+ }
3757
+
3758
+ function unsubscribe(unsubID) {
3759
+ listeners[unsubID] = undefined;
3760
+ }
3761
+
3762
+ return { publish: publish, subscribe: subscribe, unsubscribe: unsubscribe };
3673
3763
  };
3674
3764
 
3765
+ //
3766
+ // Helper to call a given function, only once
3767
+ var once = (function (cb) {
3768
+ var called = false;
3769
+
3770
+ return function () {
3771
+ if (!called) {
3772
+ called = true;
3773
+ cb();
3774
+ }
3775
+ };
3776
+ });
3777
+
3675
3778
  var _ThemeProvider$childC;
3676
3779
  var _ThemeProvider$contex;
3677
3780
 
@@ -3679,7 +3782,18 @@ var _ThemeProvider$contex;
3679
3782
  /* globals React$Element */
3680
3783
  // NOTE: DO NOT CHANGE, changing this is a semver major change!
3681
3784
  var CHANNEL = '__styled-components__';
3785
+ var CHANNEL_NEXT = CHANNEL + 'next__';
3786
+
3787
+ var CONTEXT_CHANNEL_SHAPE = index$3.shape({
3788
+ getTheme: index$3.func,
3789
+ subscribe: index$3.func,
3790
+ unsubscribe: index$3.func
3791
+ });
3682
3792
 
3793
+ var warnChannelDeprecated = once(function () {
3794
+ // eslint-disable-next-line no-console
3795
+ console.error('Warning: Usage of `context.' + CHANNEL + '` as a function is deprecated. It will be replaced with the object on `.context.' + CHANNEL_NEXT + '` in a future version.');
3796
+ });
3683
3797
  /**
3684
3798
  * Provide a theme to an entire react component tree via context and event listeners (have to do
3685
3799
  * both context and event emitter as pure components block context updates)
@@ -3693,6 +3807,8 @@ var ThemeProvider = function (_Component) {
3693
3807
 
3694
3808
  var _this = possibleConstructorReturn(this, _Component.call(this));
3695
3809
 
3810
+ _this.unsubscribeToOuterId = -1;
3811
+
3696
3812
  _this.getTheme = _this.getTheme.bind(_this);
3697
3813
  return _this;
3698
3814
  }
@@ -3702,9 +3818,9 @@ var ThemeProvider = function (_Component) {
3702
3818
 
3703
3819
  // If there is a ThemeProvider wrapper anywhere around this theme provider, merge this theme
3704
3820
  // with the outer theme
3705
- if (this.context[CHANNEL]) {
3706
- var subscribe = this.context[CHANNEL];
3707
- this.unsubscribeToOuter = subscribe(function (theme) {
3821
+ var outerContext = this.context[CHANNEL_NEXT];
3822
+ if (outerContext !== undefined) {
3823
+ this.unsubscribeToOuterId = outerContext.subscribe(function (theme) {
3708
3824
  _this2.outerTheme = theme;
3709
3825
  });
3710
3826
  }
@@ -3712,9 +3828,22 @@ var ThemeProvider = function (_Component) {
3712
3828
  };
3713
3829
 
3714
3830
  ThemeProvider.prototype.getChildContext = function getChildContext() {
3715
- var _babelHelpers$extends;
3716
-
3717
- return _extends({}, this.context, (_babelHelpers$extends = {}, _babelHelpers$extends[CHANNEL] = this.broadcast.subscribe, _babelHelpers$extends));
3831
+ var _this3 = this,
3832
+ _babelHelpers$extends;
3833
+
3834
+ return _extends({}, this.context, (_babelHelpers$extends = {}, _babelHelpers$extends[CHANNEL_NEXT] = {
3835
+ getTheme: this.getTheme,
3836
+ subscribe: this.broadcast.subscribe,
3837
+ unsubscribe: this.broadcast.unsubscribe
3838
+ }, _babelHelpers$extends[CHANNEL] = function (subscriber) {
3839
+ warnChannelDeprecated();
3840
+
3841
+ // Patch the old `subscribe` provide via `CHANNEL` for older clients.
3842
+ var unsubscribeId = _this3.broadcast.subscribe(subscriber);
3843
+ return function () {
3844
+ return _this3.broadcast.unsubscribe(unsubscribeId);
3845
+ };
3846
+ }, _babelHelpers$extends));
3718
3847
  };
3719
3848
 
3720
3849
  ThemeProvider.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
@@ -3722,8 +3851,8 @@ var ThemeProvider = function (_Component) {
3722
3851
  };
3723
3852
 
3724
3853
  ThemeProvider.prototype.componentWillUnmount = function componentWillUnmount() {
3725
- if (this.context[CHANNEL]) {
3726
- this.unsubscribeToOuter();
3854
+ if (this.unsubscribeToOuterId !== -1) {
3855
+ this.context[CHANNEL_NEXT].unsubscribe(this.unsubscribeToOuterId);
3727
3856
  }
3728
3857
  };
3729
3858
 
@@ -3755,34 +3884,22 @@ var ThemeProvider = function (_Component) {
3755
3884
  return ThemeProvider;
3756
3885
  }(React.Component);
3757
3886
 
3758
- ThemeProvider.childContextTypes = (_ThemeProvider$childC = {}, _ThemeProvider$childC[CHANNEL] = index$3.func.isRequired, _ThemeProvider$childC);
3759
- ThemeProvider.contextTypes = (_ThemeProvider$contex = {}, _ThemeProvider$contex[CHANNEL] = index$3.func, _ThemeProvider$contex);
3760
-
3761
- var _AbstractStyledCompon;
3762
-
3763
- //
3764
- var AbstractStyledComponent = function (_Component) {
3765
- inherits(AbstractStyledComponent, _Component);
3766
-
3767
- function AbstractStyledComponent() {
3768
- classCallCheck(this, AbstractStyledComponent);
3769
- return possibleConstructorReturn(this, _Component.apply(this, arguments));
3770
- }
3771
-
3772
- return AbstractStyledComponent;
3773
- }(React.Component);
3774
-
3775
- AbstractStyledComponent.contextTypes = (_AbstractStyledCompon = {}, _AbstractStyledCompon[CHANNEL] = index$3.func, _AbstractStyledCompon[CONTEXT_KEY] = index$3.instanceOf(StyleSheet), _AbstractStyledCompon);
3887
+ ThemeProvider.childContextTypes = (_ThemeProvider$childC = {}, _ThemeProvider$childC[CHANNEL] = index$3.func, _ThemeProvider$childC[CHANNEL_NEXT] = CONTEXT_CHANNEL_SHAPE, _ThemeProvider$childC);
3888
+ ThemeProvider.contextTypes = (_ThemeProvider$contex = {}, _ThemeProvider$contex[CHANNEL_NEXT] = CONTEXT_CHANNEL_SHAPE, _ThemeProvider$contex);
3776
3889
 
3777
3890
  //
3778
3891
 
3779
3892
  var escapeRegex = /[[\].#*$><+~=|^:(),"'`]/g;
3780
3893
  var multiDashRegex = /--+/g;
3781
3894
 
3895
+ // HACK for generating all static styles without needing to allocate
3896
+ // an empty execution context every single time...
3897
+ var STATIC_EXECUTION_CONTEXT = {};
3898
+
3782
3899
  var _StyledComponent = (function (ComponentStyle, constructWithOptions) {
3783
3900
  /* We depend on components having unique IDs */
3784
3901
  var identifiers = {};
3785
- var generateId = function generateId(_displayName) {
3902
+ var generateId = function generateId(_displayName, parentComponentId) {
3786
3903
  var displayName = typeof _displayName !== 'string' ? 'sc' : _displayName.replace(escapeRegex, '-') // Replace all possible CSS selectors
3787
3904
  .replace(multiDashRegex, '-'); // Replace multiple -- with single -
3788
3905
 
@@ -3790,11 +3907,12 @@ var _StyledComponent = (function (ComponentStyle, constructWithOptions) {
3790
3907
  identifiers[displayName] = nr;
3791
3908
 
3792
3909
  var hash = ComponentStyle.generateName(displayName + nr);
3793
- return displayName + '-' + hash;
3910
+ var componentId = displayName + '-' + hash;
3911
+ return parentComponentId !== undefined ? parentComponentId + '-' + componentId : componentId;
3794
3912
  };
3795
3913
 
3796
- var BaseStyledComponent = function (_AbstractStyledCompon) {
3797
- inherits(BaseStyledComponent, _AbstractStyledCompon);
3914
+ var BaseStyledComponent = function (_Component) {
3915
+ inherits(BaseStyledComponent, _Component);
3798
3916
 
3799
3917
  function BaseStyledComponent() {
3800
3918
  var _temp, _this, _ret;
@@ -3805,12 +3923,18 @@ var _StyledComponent = (function (ComponentStyle, constructWithOptions) {
3805
3923
  args[_key] = arguments[_key];
3806
3924
  }
3807
3925
 
3808
- return _ret = (_temp = (_this = possibleConstructorReturn(this, _AbstractStyledCompon.call.apply(_AbstractStyledCompon, [this].concat(args))), _this), _this.attrs = {}, _this.state = {
3926
+ return _ret = (_temp = (_this = possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.attrs = {}, _this.state = {
3809
3927
  theme: null,
3810
3928
  generatedClassName: ''
3811
- }, _temp), possibleConstructorReturn(_this, _ret);
3929
+ }, _this.unsubscribeId = -1, _temp), possibleConstructorReturn(_this, _ret);
3812
3930
  }
3813
3931
 
3932
+ BaseStyledComponent.prototype.unsubscribeFromContext = function unsubscribeFromContext() {
3933
+ if (this.unsubscribeId !== -1) {
3934
+ this.context[CHANNEL_NEXT].unsubscribe(this.unsubscribeId);
3935
+ }
3936
+ };
3937
+
3814
3938
  BaseStyledComponent.prototype.buildExecutionContext = function buildExecutionContext(theme, props) {
3815
3939
  var attrs = this.constructor.attrs;
3816
3940
 
@@ -3831,55 +3955,86 @@ var _StyledComponent = (function (ComponentStyle, constructWithOptions) {
3831
3955
 
3832
3956
  BaseStyledComponent.prototype.generateAndInjectStyles = function generateAndInjectStyles(theme, props) {
3833
3957
  var _constructor = this.constructor,
3958
+ attrs = _constructor.attrs,
3834
3959
  componentStyle = _constructor.componentStyle,
3835
3960
  warnTooManyClasses = _constructor.warnTooManyClasses;
3836
3961
 
3837
- var executionContext = this.buildExecutionContext(theme, props);
3838
3962
  var styleSheet = this.context[CONTEXT_KEY] || StyleSheet.instance;
3839
- var className = componentStyle.generateAndInjectStyles(executionContext, styleSheet);
3840
3963
 
3841
- if (warnTooManyClasses !== undefined) warnTooManyClasses(className);
3964
+ // staticaly styled-components don't need to build an execution context object,
3965
+ // and shouldn't be increasing the number of class names
3966
+ if (componentStyle.isStatic && attrs === undefined) {
3967
+ return componentStyle.generateAndInjectStyles(STATIC_EXECUTION_CONTEXT, styleSheet);
3968
+ } else {
3969
+ var executionContext = this.buildExecutionContext(theme, props);
3970
+ var className = componentStyle.generateAndInjectStyles(executionContext, styleSheet);
3971
+
3972
+ if (warnTooManyClasses !== undefined) warnTooManyClasses(className);
3842
3973
 
3843
- return className;
3974
+ return className;
3975
+ }
3844
3976
  };
3845
3977
 
3846
3978
  BaseStyledComponent.prototype.componentWillMount = function componentWillMount() {
3847
3979
  var _this2 = this;
3848
3980
 
3849
- // If there is a theme in the context, subscribe to the event emitter. This
3850
- // is necessary due to pure components blocking context updates, this circumvents
3851
- // that by updating when an event is emitted
3852
- if (this.context[CHANNEL]) {
3853
- var subscribe = this.context[CHANNEL];
3854
- this.unsubscribe = subscribe(function (nextTheme) {
3981
+ var componentStyle = this.constructor.componentStyle;
3982
+
3983
+ var styledContext = this.context[CHANNEL_NEXT];
3984
+
3985
+ // If this is a staticaly-styled component, we don't need to the theme
3986
+ // to generate or build styles.
3987
+ if (componentStyle.isStatic) {
3988
+ var generatedClassName = this.generateAndInjectStyles(STATIC_EXECUTION_CONTEXT, this.props);
3989
+ this.setState({ generatedClassName: generatedClassName });
3990
+ // If there is a theme in the context, subscribe to the event emitter. This
3991
+ // is necessary due to pure components blocking context updates, this circumvents
3992
+ // that by updating when an event is emitted
3993
+ } else if (styledContext !== undefined) {
3994
+ var subscribe = styledContext.subscribe;
3995
+
3996
+ this.unsubscribeId = subscribe(function (nextTheme) {
3855
3997
  // This will be called once immediately
3856
3998
 
3857
3999
  // Props should take precedence over ThemeProvider, which should take precedence over
3858
4000
  // defaultProps, but React automatically puts defaultProps on props.
3859
4001
  var defaultProps = _this2.constructor.defaultProps;
4002
+ /* eslint-disable react/prop-types */
3860
4003
 
3861
4004
  var isDefaultTheme = defaultProps && _this2.props.theme === defaultProps.theme;
3862
4005
  var theme = _this2.props.theme && !isDefaultTheme ? _this2.props.theme : nextTheme;
4006
+ /* eslint-enable */
3863
4007
  var generatedClassName = _this2.generateAndInjectStyles(theme, _this2.props);
3864
4008
  _this2.setState({ theme: theme, generatedClassName: generatedClassName });
3865
4009
  });
3866
4010
  } else {
4011
+ // eslint-disable-next-line react/prop-types
3867
4012
  var theme = this.props.theme || {};
3868
- var generatedClassName = this.generateAndInjectStyles(theme, this.props);
3869
- this.setState({ theme: theme, generatedClassName: generatedClassName });
4013
+ var _generatedClassName = this.generateAndInjectStyles(theme, this.props);
4014
+ this.setState({ theme: theme, generatedClassName: _generatedClassName });
3870
4015
  }
3871
4016
  };
3872
4017
 
3873
4018
  BaseStyledComponent.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
3874
4019
  var _this3 = this;
3875
4020
 
4021
+ // If this is a staticaly-styled component, we don't need to listen to
4022
+ // props changes to update styles
4023
+ var componentStyle = this.constructor.componentStyle;
4024
+
4025
+ if (componentStyle.isStatic) {
4026
+ return;
4027
+ }
4028
+
3876
4029
  this.setState(function (oldState) {
3877
4030
  // Props should take precedence over ThemeProvider, which should take precedence over
3878
4031
  // defaultProps, but React automatically puts defaultProps on props.
3879
4032
  var defaultProps = _this3.constructor.defaultProps;
4033
+ /* eslint-disable react/prop-types */
3880
4034
 
3881
4035
  var isDefaultTheme = defaultProps && nextProps.theme === defaultProps.theme;
3882
4036
  var theme = nextProps.theme && !isDefaultTheme ? nextProps.theme : oldState.theme;
4037
+ /* eslint-enable */
3883
4038
  var generatedClassName = _this3.generateAndInjectStyles(theme, nextProps);
3884
4039
 
3885
4040
  return { theme: theme, generatedClassName: generatedClassName };
@@ -3887,14 +4042,13 @@ var _StyledComponent = (function (ComponentStyle, constructWithOptions) {
3887
4042
  };
3888
4043
 
3889
4044
  BaseStyledComponent.prototype.componentWillUnmount = function componentWillUnmount() {
3890
- if (this.unsubscribe) {
3891
- this.unsubscribe();
3892
- }
4045
+ this.unsubscribeFromContext();
3893
4046
  };
3894
4047
 
3895
4048
  BaseStyledComponent.prototype.render = function render() {
3896
4049
  var _this4 = this;
3897
4050
 
4051
+ // eslint-disable-next-line react/prop-types
3898
4052
  var innerRef = this.props.innerRef;
3899
4053
  var generatedClassName = this.state.generatedClassName;
3900
4054
  var _constructor2 = this.constructor,
@@ -3904,7 +4058,9 @@ var _StyledComponent = (function (ComponentStyle, constructWithOptions) {
3904
4058
 
3905
4059
  var isTargetTag = isTag(target);
3906
4060
 
3907
- var className = [this.props.className, styledComponentId, this.attrs.className, generatedClassName].filter(Boolean).join(' ');
4061
+ var className = [
4062
+ // eslint-disable-next-line react/prop-types
4063
+ this.props.className, styledComponentId, this.attrs.className, generatedClassName].filter(Boolean).join(' ');
3908
4064
 
3909
4065
  var baseProps = _extends({}, this.attrs, {
3910
4066
  className: className
@@ -3931,7 +4087,7 @@ var _StyledComponent = (function (ComponentStyle, constructWithOptions) {
3931
4087
  };
3932
4088
 
3933
4089
  return BaseStyledComponent;
3934
- }(AbstractStyledComponent);
4090
+ }(React.Component);
3935
4091
 
3936
4092
  var createStyledComponent = function createStyledComponent(target, options, rules) {
3937
4093
  var _StyledComponent$cont;
@@ -3939,7 +4095,7 @@ var _StyledComponent = (function (ComponentStyle, constructWithOptions) {
3939
4095
  var _options$displayName = options.displayName,
3940
4096
  displayName = _options$displayName === undefined ? isTag(target) ? 'styled.' + target : 'Styled(' + getComponentName(target) + ')' : _options$displayName,
3941
4097
  _options$componentId = options.componentId,
3942
- componentId = _options$componentId === undefined ? generateId(options.displayName) : _options$componentId,
4098
+ componentId = _options$componentId === undefined ? generateId(options.displayName, options.parentComponentId) : _options$componentId,
3943
4099
  _options$ParentCompon = options.ParentComponent,
3944
4100
  ParentComponent = _options$ParentCompon === undefined ? BaseStyledComponent : _options$ParentCompon,
3945
4101
  extendingRules = options.rules,
@@ -3949,7 +4105,7 @@ var _StyledComponent = (function (ComponentStyle, constructWithOptions) {
3949
4105
  var styledComponentId = options.displayName && options.componentId ? options.displayName + '-' + options.componentId : componentId;
3950
4106
 
3951
4107
  var warnTooManyClasses = void 0;
3952
- if (typeof process !== 'undefined' && "development" !== 'production') {
4108
+ if (process.env.NODE_ENV !== 'production') {
3953
4109
  warnTooManyClasses = createWarnTooManyClasses(displayName);
3954
4110
  }
3955
4111
 
@@ -3964,27 +4120,33 @@ var _StyledComponent = (function (ComponentStyle, constructWithOptions) {
3964
4120
  }
3965
4121
 
3966
4122
  StyledComponent.withComponent = function withComponent(tag) {
3967
- var _ = options.displayName,
3968
- __ = options.componentId,
3969
- optionsToCopy = objectWithoutProperties(options, ['displayName', 'componentId']);
4123
+ var previousComponentId = options.componentId,
4124
+ optionsToCopy = objectWithoutProperties(options, ['componentId']);
4125
+
4126
+
4127
+ var newComponentId = previousComponentId && previousComponentId + '-' + (isTag(tag) ? tag : getComponentName(tag));
4128
+
4129
+ var newOptions = _extends({}, optionsToCopy, {
4130
+ componentId: newComponentId,
4131
+ ParentComponent: StyledComponent
4132
+ });
3970
4133
 
3971
- var newOptions = _extends({}, optionsToCopy, { ParentComponent: StyledComponent });
3972
4134
  return createStyledComponent(tag, newOptions, rules);
3973
4135
  };
3974
4136
 
3975
4137
  createClass(StyledComponent, null, [{
3976
4138
  key: 'extend',
3977
4139
  get: function get$$1() {
3978
- var _ = options.displayName,
3979
- __ = options.componentId,
3980
- rulesFromOptions = options.rules,
3981
- optionsToCopy = objectWithoutProperties(options, ['displayName', 'componentId', 'rules']);
4140
+ var rulesFromOptions = options.rules,
4141
+ parentComponentId = options.componentId,
4142
+ optionsToCopy = objectWithoutProperties(options, ['rules', 'componentId']);
3982
4143
 
3983
4144
 
3984
4145
  var newRules = rulesFromOptions === undefined ? rules : rulesFromOptions.concat(rules);
3985
4146
 
3986
4147
  var newOptions = _extends({}, optionsToCopy, {
3987
4148
  rules: newRules,
4149
+ parentComponentId: parentComponentId,
3988
4150
  ParentComponent: StyledComponent
3989
4151
  });
3990
4152
 
@@ -3994,7 +4156,7 @@ var _StyledComponent = (function (ComponentStyle, constructWithOptions) {
3994
4156
  return StyledComponent;
3995
4157
  }(ParentComponent);
3996
4158
 
3997
- StyledComponent.contextTypes = (_StyledComponent$cont = {}, _StyledComponent$cont[CHANNEL] = index$3.func, _StyledComponent$cont[CONTEXT_KEY] = index$3.instanceOf(StyleSheet), _StyledComponent$cont);
4159
+ StyledComponent.contextTypes = (_StyledComponent$cont = {}, _StyledComponent$cont[CHANNEL] = index$3.func, _StyledComponent$cont[CHANNEL_NEXT] = CONTEXT_CHANNEL_SHAPE, _StyledComponent$cont[CONTEXT_KEY] = index$3.instanceOf(StyleSheet), _StyledComponent$cont);
3998
4160
  StyledComponent.displayName = displayName;
3999
4161
  StyledComponent.styledComponentId = styledComponentId;
4000
4162
  StyledComponent.attrs = attrs;
@@ -4075,6 +4237,23 @@ function Umul32(n, m) {
4075
4237
  }
4076
4238
 
4077
4239
  //
4240
+ var isStaticRules = function isStaticRules(rules) {
4241
+ for (var i = 0; i < rules.length; i += 1) {
4242
+ var rule = rules[i];
4243
+
4244
+ // recursive case
4245
+ if (Array.isArray(rule) && !isStaticRules(rule)) {
4246
+ return false;
4247
+ } else if (typeof rule === 'function' && !isStyledComponent(rule)) {
4248
+ // functions are allowed to be static if they're just being
4249
+ // used to get the classname of a nested styled copmonent
4250
+ return false;
4251
+ }
4252
+ }
4253
+
4254
+ return true;
4255
+ };
4256
+
4078
4257
  /*
4079
4258
  ComponentStyle is all the CSS-specific stuff, not
4080
4259
  the React-specific stuff.
@@ -4085,9 +4264,10 @@ var _ComponentStyle = (function (nameGenerator, flatten, stringifyRules) {
4085
4264
  classCallCheck(this, ComponentStyle);
4086
4265
 
4087
4266
  this.rules = rules;
4267
+ this.isStatic = isStaticRules(rules);
4088
4268
  this.componentId = componentId;
4089
4269
  if (!StyleSheet.instance.hasInjectedComponent(this.componentId)) {
4090
- var placeholder = '.' + componentId + ' {}';
4270
+ var placeholder = process.env.NODE_ENV !== 'production' ? '.' + componentId + ' {}' : '';
4091
4271
  StyleSheet.instance.deferredInject(componentId, true, placeholder);
4092
4272
  }
4093
4273
  }
@@ -4100,16 +4280,36 @@ var _ComponentStyle = (function (nameGenerator, flatten, stringifyRules) {
4100
4280
 
4101
4281
 
4102
4282
  ComponentStyle.prototype.generateAndInjectStyles = function generateAndInjectStyles(executionContext, styleSheet) {
4283
+ var isStatic = this.isStatic,
4284
+ lastClassName = this.lastClassName;
4285
+
4286
+ if (isStatic && lastClassName !== undefined) {
4287
+ return lastClassName;
4288
+ }
4289
+
4103
4290
  var flatCSS = flatten(this.rules, executionContext);
4104
4291
  var hash = doHash(this.componentId + flatCSS.join(''));
4105
4292
 
4106
4293
  var existingName = styleSheet.getName(hash);
4107
- if (existingName) return existingName;
4294
+ if (existingName !== undefined) {
4295
+ if (styleSheet.stylesCacheable) {
4296
+ this.lastClassName = existingName;
4297
+ }
4298
+ return existingName;
4299
+ }
4108
4300
 
4109
4301
  var name = nameGenerator(hash);
4110
- if (styleSheet.alreadyInjected(hash, name)) return name;
4302
+ if (styleSheet.stylesCacheable) {
4303
+ this.lastClassName = existingName;
4304
+ }
4305
+ if (styleSheet.alreadyInjected(hash, name)) {
4306
+ return name;
4307
+ }
4111
4308
 
4112
4309
  var css = '\n' + stringifyRules(flatCSS, '.' + name);
4310
+ // NOTE: this can only be set when we inject the class-name.
4311
+ // For some reason, presumably due to how css is stringifyRules behaves in
4312
+ // differently between client and server, styles break.
4113
4313
  styleSheet.inject(this.componentId, true, css, hash, name);
4114
4314
  return name;
4115
4315
  };
@@ -4127,7 +4327,7 @@ var _ComponentStyle = (function (nameGenerator, flatten, stringifyRules) {
4127
4327
  //
4128
4328
  // Thanks to ReactDOMFactories for this handy list!
4129
4329
 
4130
- var domElements = ['a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'cite', 'code', 'col', 'colgroup', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'menu', 'menuitem', 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr',
4330
+ var domElements = ['a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'cite', 'code', 'col', 'colgroup', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr',
4131
4331
 
4132
4332
  // SVG
4133
4333
  'circle', 'clipPath', 'defs', 'ellipse', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'svg', 'text', 'tspan'];
@@ -4298,7 +4498,7 @@ var wrapWithTheme = function wrapWithTheme(Component$$1) {
4298
4498
  args[_key] = arguments[_key];
4299
4499
  }
4300
4500
 
4301
- return _ret = (_temp = (_this = possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = {}, _temp), possibleConstructorReturn(_this, _ret);
4501
+ return _ret = (_temp = (_this = possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = {}, _this.unsubscribeId = -1, _temp), possibleConstructorReturn(_this, _ret);
4302
4502
  }
4303
4503
 
4304
4504
  // NOTE: This is so that isStyledComponent passes for the innerRef unwrapping
@@ -4307,18 +4507,24 @@ var wrapWithTheme = function wrapWithTheme(Component$$1) {
4307
4507
  WithTheme.prototype.componentWillMount = function componentWillMount() {
4308
4508
  var _this2 = this;
4309
4509
 
4310
- if (!this.context[CHANNEL]) {
4311
- throw new Error('[withTheme] Please use ThemeProvider to be able to use withTheme');
4510
+ var styledContext = this.context[CHANNEL_NEXT];
4511
+ if (styledContext === undefined) {
4512
+ // eslint-disable-next-line no-console
4513
+ console.error('[withTheme] Please use ThemeProvider to be able to use withTheme');
4514
+ return;
4312
4515
  }
4313
4516
 
4314
- var subscribe = this.context[CHANNEL];
4315
- this.unsubscribe = subscribe(function (theme) {
4517
+ var subscribe = styledContext.subscribe;
4518
+
4519
+ this.unsubscribeId = subscribe(function (theme) {
4316
4520
  _this2.setState({ theme: theme });
4317
4521
  });
4318
4522
  };
4319
4523
 
4320
4524
  WithTheme.prototype.componentWillUnmount = function componentWillUnmount() {
4321
- if (typeof this.unsubscribe === 'function') this.unsubscribe();
4525
+ if (this.unsubscribeId !== -1) {
4526
+ this.context[CHANNEL_NEXT].unsubscribe(this.unsubscribeId);
4527
+ }
4322
4528
  };
4323
4529
 
4324
4530
  WithTheme.prototype.render = function render() {
@@ -4340,7 +4546,7 @@ var wrapWithTheme = function wrapWithTheme(Component$$1) {
4340
4546
 
4341
4547
  WithTheme.displayName = 'WithTheme(' + componentName + ')';
4342
4548
  WithTheme.styledComponentId = 'withTheme';
4343
- WithTheme.contextTypes = (_WithTheme$contextTyp = {}, _WithTheme$contextTyp[CHANNEL] = index$3.func, _WithTheme$contextTyp);
4549
+ WithTheme.contextTypes = (_WithTheme$contextTyp = {}, _WithTheme$contextTyp[CHANNEL] = index$3.func, _WithTheme$contextTyp[CHANNEL_NEXT] = CONTEXT_CHANNEL_SHAPE, _WithTheme$contextTyp);
4344
4550
 
4345
4551
 
4346
4552
  return index$5(WithTheme, Component$$1);