Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1013 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | "use strict";
|
---|
| 2 |
|
---|
| 3 | /* istanbul ignore next */
|
---|
| 4 | function apply(style, options, obj) {
|
---|
| 5 | var css = obj.css;
|
---|
| 6 | var media = obj.media;
|
---|
| 7 | var sourceMap = obj.sourceMap;
|
---|
| 8 |
|
---|
| 9 | if (media) {
|
---|
| 10 | style.setAttribute("media", media);
|
---|
| 11 | } else {
|
---|
| 12 | style.removeAttribute("media");
|
---|
| 13 | }
|
---|
| 14 |
|
---|
| 15 | if (sourceMap && typeof btoa !== "undefined") {
|
---|
| 16 | css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
|
---|
| 17 | } // For old IE
|
---|
| 18 |
|
---|
| 19 | /* istanbul ignore if */
|
---|
| 20 |
|
---|
| 21 |
|
---|
| 22 | options.styleTagTransform(css, style);
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | function removeStyleElement(style) {
|
---|
| 26 | // istanbul ignore if
|
---|
| 27 | if (style.parentNode === null) {
|
---|
| 28 | return false;
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | style.parentNode.removeChild(style);
|
---|
| 32 | }
|
---|
| 33 | /* istanbul ignore next */
|
---|
| 34 |
|
---|
| 35 |
|
---|
| 36 | function domAPI(options) {
|
---|
| 37 | var style = options.insertStyleElement(options);
|
---|
| 38 | return {
|
---|
| 39 | update: function update(obj) {
|
---|
| 40 | apply(style, options, obj);
|
---|
| 41 | },
|
---|
| 42 | remove: function remove() {
|
---|
| 43 | removeStyleElement(style);
|
---|
| 44 | }
|
---|
| 45 | };
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | module.exports = domAPI; |
---|
Note:
See
TracBrowser
for help on using the repository browser.