source: imaps-frontend/node_modules/nano-css/addon/cssom.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.3 KB
Line 
1'use strict';
2
3exports.addon = function (renderer) {
4 // CSSOM support only browser environment.
5 if (!renderer.client) return;
6
7 if (process.env.NODE_ENV !== 'production') {
8 require('./__dev__/warnOnMissingDependencies')('cssom', renderer, ['sh']);
9 }
10
11 // Style sheet for media queries.
12 document.head.appendChild(renderer.msh = document.createElement('style'));
13
14 renderer.createRule = function (selector, prelude) {
15 var rawCss = selector + '{}';
16 if (prelude) rawCss = prelude + '{' + rawCss + '}';
17 var sheet = prelude ? renderer.msh.sheet : renderer.sh.sheet;
18 var index = sheet.insertRule(rawCss, sheet.cssRules.length);
19 var rule = (sheet.cssRules || sheet.rules)[index];
20
21 // Keep track of `index` where rule was inserted in the sheet. This is
22 // needed for rule deletion.
23 rule.index = index;
24
25 if (prelude) {
26 // If rule has media query (it has prelude), move style (CSSStyleDeclaration)
27 // object to the "top" to normalize it with a rule without the media
28 // query, so that both rules have `.style` property available.
29 var selectorRule = (rule.cssRules || rule.rules)[0];
30 rule.style = selectorRule.style;
31 rule.styleMap = selectorRule.styleMap;
32 }
33
34 return rule;
35 };
36};
Note: See TracBrowser for help on using the repository browser.