| [9af201e] | 1 | "use strict";
|
|---|
| 2 |
|
|---|
| 3 | /* istanbul ignore next */
|
|---|
| 4 | function apply(styleElement, options, obj) {
|
|---|
| 5 | var css = "";
|
|---|
| 6 | if (obj.supports) {
|
|---|
| 7 | css += "@supports (".concat(obj.supports, ") {");
|
|---|
| 8 | }
|
|---|
| 9 | if (obj.media) {
|
|---|
| 10 | css += "@media ".concat(obj.media, " {");
|
|---|
| 11 | }
|
|---|
| 12 | var needLayer = typeof obj.layer !== "undefined";
|
|---|
| 13 | if (needLayer) {
|
|---|
| 14 | css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
|
|---|
| 15 | }
|
|---|
| 16 | css += obj.css;
|
|---|
| 17 | if (needLayer) {
|
|---|
| 18 | css += "}";
|
|---|
| 19 | }
|
|---|
| 20 | if (obj.media) {
|
|---|
| 21 | css += "}";
|
|---|
| 22 | }
|
|---|
| 23 | if (obj.supports) {
|
|---|
| 24 | css += "}";
|
|---|
| 25 | }
|
|---|
| 26 | var sourceMap = obj.sourceMap;
|
|---|
| 27 | if (sourceMap && typeof btoa !== "undefined") {
|
|---|
| 28 | css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | // For old IE
|
|---|
| 32 | /* istanbul ignore if */
|
|---|
| 33 | options.styleTagTransform(css, styleElement, options.options);
|
|---|
| 34 | }
|
|---|
| 35 | function removeStyleElement(styleElement) {
|
|---|
| 36 | // istanbul ignore if
|
|---|
| 37 | if (styleElement.parentNode === null) {
|
|---|
| 38 | return false;
|
|---|
| 39 | }
|
|---|
| 40 | styleElement.parentNode.removeChild(styleElement);
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 | /* istanbul ignore next */
|
|---|
| 44 | function domAPI(options) {
|
|---|
| 45 | if (typeof document === "undefined") {
|
|---|
| 46 | return {
|
|---|
| 47 | update: function update() {},
|
|---|
| 48 | remove: function remove() {}
|
|---|
| 49 | };
|
|---|
| 50 | }
|
|---|
| 51 | var styleElement = options.insertStyleElement(options);
|
|---|
| 52 | return {
|
|---|
| 53 | update: function update(obj) {
|
|---|
| 54 | apply(styleElement, options, obj);
|
|---|
| 55 | },
|
|---|
| 56 | remove: function remove() {
|
|---|
| 57 | removeStyleElement(styleElement);
|
|---|
| 58 | }
|
|---|
| 59 | };
|
|---|
| 60 | }
|
|---|
| 61 | module.exports = domAPI; |
|---|