-
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathhydrate.js
More file actions
40 lines (30 loc) · 1.02 KB
/
hydrate.js
File metadata and controls
40 lines (30 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict';
exports.addon = function (renderer) {
if (process.env.NODE_ENV !== 'production') {
require('./__dev__/warnOnMissingDependencies')('hydrate', renderer, ['put']);
}
if (renderer.client) {
var hydrated = {};
var stylesheet = renderer.sh;
if (!stylesheet) {
if (process.env.NODE_ENV !== 'production') {
console.error('Hydration style sheet was not found.');
}
return;
}
var cssRules = stylesheet.cssRules;
for (var i = 0; i < cssRules.length; i++)
hydrated[cssRules[i].selectorText] = 1;
var put = renderer.put;
renderer.put = function (selector, css) {
if (selector in hydrated) {
if (process.env.NODE_ENV !== 'production') {
// eslint-disable-next-line
console.info('Hydrated selector: ' + selector);
}
return;
}
put(selector, css);
};
}
};