(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o...` element from the named text string(s) and inserts it but only if it does not already exist in the specified container as per `referenceElement`. * * > Caveat: If stylesheet is for use in a shadow DOM, you must specify a local `referenceElement`. * * @returns A reference to the newly created `` element. * * @param {string|string[]} cssRules * @param {string} [ID] * @param {undefined|null|Element|string} [referenceElement] - Container for insertion. Overloads: * * `undefined` type (or omitted): injects stylesheet at top of `...` element * * `null` value: injects stylesheet at bottom of `...` element * * `Element` type: injects stylesheet immediately before given element, wherever it is found. * * `string` type: injects stylesheet immediately before given first element found that matches the given css selector. * * @memberOf cssInjector */ function cssInjector(cssRules, ID, referenceElement) { if (typeof referenceElement === 'string') { referenceElement = document.querySelector(referenceElement); if (!referenceElement) { throw 'Cannot find reference element for CSS injection.'; } } else if (referenceElement && !(referenceElement instanceof Element)) { throw 'Given value not a reference element.'; } var container = referenceElement && referenceElement.parentNode || document.head || document.getElementsByTagName('head')[0]; if (ID) { ID = cssInjector.idPrefix + ID; if (container.querySelector('#' + ID)) { return; // stylesheet already in DOM } } var style = document.createElement('style'); style.type = 'text/css'; if (ID) { style.id = ID; } if (cssRules instanceof Array) { cssRules = cssRules.join('\n'); } cssRules = '\n' + cssRules + '\n'; if (style.styleSheet) { style.styleSheet.cssText = cssRules; } else { style.appendChild(document.createTextNode(cssRules)); } if (referenceElement === undefined) { referenceElement = container.firstChild; } container.insertBefore(style, referenceElement); return style; } /** * @summary Optional prefix for `