0b17e8f0a56d9a33a3fd0fdbde3e5048.json
6.15 KB
{"ast":null,"code":"var containers = []; // will store container HTMLElement references\n\nvar styleElements = []; // will store {prepend: HTMLElement, append: HTMLElement}\n\nvar usage = 'insert-css: You need to provide a CSS string. Usage: insertCss(cssString[, options]).';\n\nfunction insertCss(css, options) {\n options = options || {};\n\n if (css === undefined) {\n throw new Error(usage);\n }\n\n var position = options.prepend === true ? 'prepend' : 'append';\n var container = options.container !== undefined ? options.container : document.querySelector('head');\n var containerId = containers.indexOf(container); // first time we see this container, create the necessary entries\n\n if (containerId === -1) {\n containerId = containers.push(container) - 1;\n styleElements[containerId] = {};\n } // try to get the correponding container + position styleElement, create it otherwise\n\n\n var styleElement;\n\n if (styleElements[containerId] !== undefined && styleElements[containerId][position] !== undefined) {\n styleElement = styleElements[containerId][position];\n } else {\n styleElement = styleElements[containerId][position] = createStyleElement();\n\n if (position === 'prepend') {\n container.insertBefore(styleElement, container.childNodes[0]);\n } else {\n container.appendChild(styleElement);\n }\n } // strip potential UTF-8 BOM if css was read from a file\n\n\n if (css.charCodeAt(0) === 0xFEFF) {\n css = css.substr(1, css.length);\n } // actually add the stylesheet\n\n\n if (styleElement.styleSheet) {\n styleElement.styleSheet.cssText += css;\n } else {\n styleElement.textContent += css;\n }\n\n return styleElement;\n}\n\n;\n\nfunction createStyleElement() {\n var styleElement = document.createElement('style');\n styleElement.setAttribute('type', 'text/css');\n return styleElement;\n}\n\nmodule.exports = insertCss;\nmodule.exports.insertCss = insertCss;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/insert-css/index.js"],"names":["containers","styleElements","usage","insertCss","css","options","undefined","Error","position","prepend","container","document","querySelector","containerId","indexOf","push","styleElement","createStyleElement","insertBefore","childNodes","appendChild","charCodeAt","substr","length","styleSheet","cssText","textContent","createElement","setAttribute","module","exports"],"mappings":"AAAA,IAAIA,UAAU,GAAG,EAAjB,C,CAAqB;;AACrB,IAAIC,aAAa,GAAG,EA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MAAAA,SAAS,CAACU,WAAV,CAAsBJ,YAAtB;AACH;AACJ,GA9B4B,CAgC7B;;;AACA,MAAIZ,GAAG,CAACiB,UAAJ,CAAe,CAAf,MAAsB,MAA1B,EAAkC;AAAEjB,IAAAA,GAAG,GAAGA,GAAG,CAACkB,MAAJ,CAAW,CAAX,EAAclB,GAAG,CAACmB,MAAlB,CAAN;AAAkC,GAjCzC,CAmC7B;;;AACA,MAAIP,YAAY,CAACQ,UAAjB,EAA6B;AACzBR,IAAAA,YAAY,CAACQ,UAAb,CAAwBC,OAAxB,IAAmCrB,GAAnC;AACH,GAFD,MAEO;AACHY,IAAAA,YAAY,CAACU,WAAb,IAA4BtB,GAA5B;AACH;;AAED,SAAOY,YAAP;AACH;;AAAA;;AAED,SAASC,kBAAT,GAA8B;AAC1B,MAAID,YAAY,GAAGL,QAAQ,CAACgB,aAAT,CAAuB,OAAvB,CAAnB;AACAX,EAAAA,YAAY,CAACY,YAAb,CAA0B,MAA1B,EAAkC,UAAlC;AACA,SAAOZ,YAAP;AACH;;AAEDa,MAAM,CAACC,OAAP,GAAiB3B,SAAjB;AACA0B,MAAM,CAACC,OAAP,CAAe3B,SAAf,GAA2BA,SAA3B","sourcesContent":["var containers = []; // will store container HTMLElement references\nvar styleElements = []; // will store {prepend: HTMLElement, append: HTMLElement}\n\nvar usage = 'insert-css: You need to provide a CSS string. Usage: insertCss(cssString[, options]).';\n\nfunction insertCss(css, options) {\n options = options || {};\n\n if (css === undefined) {\n throw new Error(usage);\n }\n\n var position = options.prepend === true ? 'prepend' : 'append';\n var container = options.container !== undefined ? options.container : document.querySelector('head');\n var containerId = containers.indexOf(container);\n\n // first time we see this container, create the necessary entries\n if (containerId === -1) {\n containerId = containers.push(container) - 1;\n styleElements[containerId] = {};\n }\n\n // try to get the correponding container + position styleElement, create it otherwise\n var styleElement;\n\n if (styleElements[containerId] !== undefined && styleElements[containerId][position] !== undefined) {\n styleElement = styleElements[containerId][position];\n } else {\n styleElement = styleElements[containerId][position] = createStyleElement();\n\n if (position === 'prepend') {\n container.insertBefore(styleElement, container.childNodes[0]);\n } else {\n container.appendChild(styleElement);\n }\n }\n\n // strip potential UTF-8 BOM if css was read from a file\n if (css.charCodeAt(0) === 0xFEFF) { css = css.substr(1, css.length); }\n\n // actually add the stylesheet\n if (styleElement.styleSheet) {\n styleElement.styleSheet.cssText += css\n } else {\n styleElement.textContent += css;\n }\n\n return styleElement;\n};\n\nfunction createStyleElement() {\n var styleElement = document.createElement('style');\n styleElement.setAttribute('type', 'text/css');\n return styleElement;\n}\n\nmodule.exports = insertCss;\nmodule.exports.insertCss = insertCss;\n"]},"metadata":{},"sourceType":"script"}