main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | exports.addon = function (renderer) {
|
---|
4 | if (renderer.client) {
|
---|
5 | console.error(
|
---|
6 | 'You are running nano-css "extract" addon in browser. ' +
|
---|
7 | 'You should use it ONLY on server and ONLY at build time.'
|
---|
8 | );
|
---|
9 |
|
---|
10 | return;
|
---|
11 | }
|
---|
12 |
|
---|
13 | var sheet = renderer.sheet;
|
---|
14 |
|
---|
15 | // eslint-disable-next-line no-unused-vars
|
---|
16 | var dummy;
|
---|
17 |
|
---|
18 | // Evaluate all lazy-evaluated sheet() styles.
|
---|
19 | if (sheet) {
|
---|
20 | renderer.sheet = function (map) {
|
---|
21 | var styles = sheet.apply(this, arguments);
|
---|
22 |
|
---|
23 | for (var name in map) dummy = styles[name];
|
---|
24 |
|
---|
25 | return styles;
|
---|
26 | };
|
---|
27 | }
|
---|
28 |
|
---|
29 | var jsx = renderer.jsx;
|
---|
30 |
|
---|
31 | // Render jsx component once to extract its static CSS.
|
---|
32 | if (jsx) {
|
---|
33 | renderer.jsx = function () {
|
---|
34 | var jsxComponent = jsx.apply(this, arguments);
|
---|
35 |
|
---|
36 | process.nextTick(function () {
|
---|
37 | jsxComponent(jsxComponent.defaultProps || {});
|
---|
38 | });
|
---|
39 |
|
---|
40 | return jsxComponent;
|
---|
41 | };
|
---|
42 | }
|
---|
43 |
|
---|
44 | var style = renderer.style;
|
---|
45 |
|
---|
46 | // Render styled component once with default props
|
---|
47 | // to extract its static CSS and "default" dynamic CSS.
|
---|
48 | if (style) {
|
---|
49 | renderer.style = function () {
|
---|
50 | var styledComponent = style.apply(this, arguments);
|
---|
51 |
|
---|
52 | process.nextTick(function () {
|
---|
53 | styledComponent(styledComponent.defaultProps || {});
|
---|
54 | });
|
---|
55 |
|
---|
56 | return styledComponent;
|
---|
57 | };
|
---|
58 | }
|
---|
59 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.