main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | exports.addon = function (renderer) {
|
---|
4 | if (process.env.NODE_ENV !== 'production') {
|
---|
5 | require('./__dev__/warnOnMissingDependencies')('rule', renderer, ['put']);
|
---|
6 | }
|
---|
7 |
|
---|
8 | var blocks;
|
---|
9 |
|
---|
10 | if (process.env.NODE_ENV !== 'production') {
|
---|
11 | blocks = {};
|
---|
12 | }
|
---|
13 |
|
---|
14 | renderer.rule = function (css, block) {
|
---|
15 | // Warn user if CSS selectors clash.
|
---|
16 | if (process.env.NODE_ENV !== 'production') {
|
---|
17 | if (block) {
|
---|
18 | if (typeof block !== 'string') {
|
---|
19 | throw new TypeError(
|
---|
20 | 'nano-css block name must be a string. ' +
|
---|
21 | 'For example, use nano.rule({color: "red", "RedText").'
|
---|
22 | );
|
---|
23 | }
|
---|
24 |
|
---|
25 | if (blocks[block]) {
|
---|
26 | console.error('Block name "' + block + '" used more than once.');
|
---|
27 | }
|
---|
28 |
|
---|
29 | blocks[block] = 1;
|
---|
30 | }
|
---|
31 | }
|
---|
32 |
|
---|
33 | block = block || renderer.hash(css);
|
---|
34 | block = renderer.pfx + block;
|
---|
35 | renderer.put('.' + block, css);
|
---|
36 |
|
---|
37 | return ' ' + block;
|
---|
38 | };
|
---|
39 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.