diff --git a/README.md b/README.md index 4f66e90a..a51b23f8 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,16 @@ Styles are not added on `require`, but instead on call to `use`/`ref`. Styles ar Note: Behavior is undefined when `unuse`/`unref` is called more often than `use`/`ref`. Don't do that. +#### Iframe support + +Each `use/ref` call can also take an optional `DOMElement` parameter to tell `style-loader` where to append the resulting link/style tag(s) to (for usage with Iframes etc.): + +```javascript +var iframe = document.getElementsByTagName('iframe')[0]; +style.use(iframe.contentDocument.head); // = style.ref(iframe.contentDocument.head); +style.unuse(); // = style.unref(); +``` + ### Options #### `insertAt` diff --git a/addStyles.js b/addStyles.js index ef4fd5fd..01ac525f 100644 --- a/addStyles.js +++ b/addStyles.js @@ -20,7 +20,7 @@ var stylesInDom = {}, singletonCounter = 0, styleElementsInsertedAtTop = []; -module.exports = function(list, options) { +module.exports = function(list, options, parentElement) { if(typeof DEBUG !== "undefined" && DEBUG) { if(typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment"); } @@ -33,8 +33,11 @@ module.exports = function(list, options) { // By default, add