source: trip-planner-front/node_modules/style-loader/dist/runtime/singletonStyleDomAPI.js@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.5 KB
RevLine 
[6a3a178]1"use strict";
2
3/* istanbul ignore next */
4var replaceText = function replaceText() {
5 var textStore = [];
6 return function replace(index, replacement) {
7 textStore[index] = replacement;
8 return textStore.filter(Boolean).join("\n");
9 };
10}();
11/* istanbul ignore next */
12
13
14function apply(style, index, remove, obj) {
15 var css = remove ? "" : obj.media ? "@media ".concat(obj.media, " {").concat(obj.css, "}") : obj.css; // For old IE
16
17 /* istanbul ignore if */
18
19 if (style.styleSheet) {
20 style.styleSheet.cssText = replaceText(index, css);
21 } else {
22 var cssNode = document.createTextNode(css);
23 var childNodes = style.childNodes;
24
25 if (childNodes[index]) {
26 style.removeChild(childNodes[index]);
27 }
28
29 if (childNodes.length) {
30 style.insertBefore(cssNode, childNodes[index]);
31 } else {
32 style.appendChild(cssNode);
33 }
34 }
35}
36
37var singletonData = {
38 singleton: null,
39 singletonCounter: 0
40};
41/* istanbul ignore next */
42
43function domAPI(options) {
44 // eslint-disable-next-line no-undef,no-use-before-define
45 var styleIndex = singletonData.singletonCounter++;
46 var style = // eslint-disable-next-line no-undef,no-use-before-define
47 singletonData.singleton || ( // eslint-disable-next-line no-undef,no-use-before-define
48 singletonData.singleton = options.insertStyleElement(options));
49 return {
50 update: function update(obj) {
51 apply(style, styleIndex, false, obj);
52 },
53 remove: function remove(obj) {
54 apply(style, styleIndex, true, obj);
55 }
56 };
57}
58
59module.exports = domAPI;
Note: See TracBrowser for help on using the repository browser.