source: imaps-frontend/node_modules/nano-css/addon/stylis/plugin-onRule.js

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.1 KB
Line 
1'use strict';
2
3module.exports = function (insertRule) {
4 var delimiter = '/*|*/';
5 var needle = delimiter + '}';
6
7 function toSheet (block) {
8 if (block)
9 try {
10 insertRule(block + '}');
11 } catch (e) {
12 // eslint-disable-next-line
13 };
14 }
15
16 return function ruleSheet (context, content, selectors, parents, line, column, length, ns, depth, at) {
17 switch (context) {
18 // property
19 case 1:
20 // @import
21 if (depth === 0 && content.charCodeAt(0) === 64)
22 return insertRule(content+';'), '';
23 break;
24 // selector
25 case 2:
26 if (ns === 0)
27 return content + delimiter;
28 break;
29 // at-rule
30 case 3:
31 switch (ns) {
32 // @font-face, @page
33 case 102:
34 case 112:
35 return insertRule(selectors[0]+content), '';
36 default:
37 return content + (at === 0 ? delimiter : '');
38 }
39 case -2:
40 content.split(needle).forEach(toSheet);
41 }
42 };
43};
Note: See TracBrowser for help on using the repository browser.