12345678910111213141516171819202122232425262728293031323334 |
- "use strict";
- var memo = {};
- function getTarget(target) {
- if (typeof memo[target] === "undefined") {
- var styleTarget = document.querySelector(target);
-
- if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
- try {
-
-
- styleTarget = styleTarget.contentDocument.head;
- } catch (e) {
-
- styleTarget = null;
- }
- }
- memo[target] = styleTarget;
- }
- return memo[target];
- }
- function insertBySelector(insert, style) {
- var target = getTarget(insert);
- if (!target) {
- throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
- }
- target.appendChild(style);
- }
- module.exports = insertBySelector;
|