12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- "use strict";
- /* istanbul ignore next */
- function apply(styleElement, options, obj) {
- var css = "";
- if (obj.supports) {
- css += "@supports (".concat(obj.supports, ") {");
- }
- if (obj.media) {
- css += "@media ".concat(obj.media, " {");
- }
- var needLayer = typeof obj.layer !== "undefined";
- if (needLayer) {
- css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
- }
- css += obj.css;
- if (needLayer) {
- css += "}";
- }
- if (obj.media) {
- css += "}";
- }
- if (obj.supports) {
- css += "}";
- }
- var sourceMap = obj.sourceMap;
- if (sourceMap && typeof btoa !== "undefined") {
- css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
- }
- // For old IE
- /* istanbul ignore if */
- options.styleTagTransform(css, styleElement, options.options);
- }
- function removeStyleElement(styleElement) {
- // istanbul ignore if
- if (styleElement.parentNode === null) {
- return false;
- }
- styleElement.parentNode.removeChild(styleElement);
- }
- /* istanbul ignore next */
- function domAPI(options) {
- if (typeof document === "undefined") {
- return {
- update: function update() {},
- remove: function remove() {}
- };
- }
- var styleElement = options.insertStyleElement(options);
- return {
- update: function update(obj) {
- apply(styleElement, options, obj);
- },
- remove: function remove() {
- removeStyleElement(styleElement);
- }
- };
- }
- module.exports = domAPI;
|