-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
53 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
'use strict'; | ||
|
||
exports.addon = function (renderer, id) { | ||
id = id || 'nano-css'; | ||
|
||
if (process.env.NODE_ENV !== 'production') { | ||
require('./__dev__/warnOnMissingDependencies')('hydrate', renderer, ['put']); | ||
} | ||
|
||
if (renderer.client) { | ||
var hydrated = {}; | ||
var stylesheet = document.getElementById(id); | ||
|
||
if (!stylesheet) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
console.error('Hydration stylesheet with id "' + id + '" was not found.'); | ||
} | ||
|
||
return; | ||
} | ||
|
||
var cssRules = stylesheet.cssRules; | ||
|
||
for (var i = 0; i < cssRules.length; i++) { | ||
var rule = cssRules[i]; | ||
hydrated[rule.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); | ||
}; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters