Skip to content

Commit b82f57b

Browse files
committed
allow to insert css into an iframe by allowing to specify an alternative document in the options object
1 parent acc7f46 commit b82f57b

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ var inserted = {};
33
module.exports = function (css, options) {
44
if (inserted[css]) return;
55
inserted[css] = true;
6-
7-
var elem = document.createElement('style');
6+
7+
var doc = options.document || document;
8+
var elem = doc.createElement('style');
89
elem.setAttribute('type', 'text/css');
910

1011
if ('textContent' in elem) {
@@ -13,7 +14,7 @@ module.exports = function (css, options) {
1314
elem.styleSheet.cssText = css;
1415
}
1516

16-
var head = document.getElementsByTagName('head')[0];
17+
var head = doc.getElementsByTagName('head')[0];
1718
if (options && options.prepend) {
1819
head.insertBefore(elem, head.childNodes[0]);
1920
} else {

0 commit comments

Comments
 (0)