Comparing version 0.1.1 to 0.2.0
var inserted = {}; | ||
module.exports = function (css) { | ||
module.exports = function (css, options) { | ||
if (inserted[css]) return; | ||
@@ -17,3 +17,7 @@ inserted[css] = true; | ||
var head = document.getElementsByTagName('head')[0]; | ||
head.appendChild(elem); | ||
if (options && options.prepend) { | ||
head.insertBefore(elem, head.childNodes[0]); | ||
} else { | ||
head.appendChild(elem); | ||
} | ||
}; |
{ | ||
"name": "insert-css", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "insert a string of css into the <head>", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"tape": "~2.4.0", | ||
"tape": "^2.13.3", | ||
"computed-style": "~0.1.3" | ||
@@ -11,0 +11,0 @@ }, |
@@ -8,3 +8,3 @@ var test = require('tape'); | ||
test(function (t) { | ||
t.plan(6); | ||
t.plan(10); | ||
@@ -15,3 +15,3 @@ var before = colors(); | ||
insertCss(css); | ||
insertCss(css, { prepend: true }); | ||
@@ -28,2 +28,16 @@ var after = colors(); | ||
t.ok(reset.fg === 'rgb(0,0,0)' || reset.fg === '#000000'); | ||
var resetStyle = 'body { background-color: green; color: pink; }'; | ||
insertCss(resetStyle, { prepend: true }); | ||
var reset = colors(); | ||
t.ok(reset.bg === 'rgba(0,0,0,0)' || reset.bg === 'transparent'); | ||
t.ok(reset.fg === 'rgb(0,0,0)' || reset.fg === '#000000'); | ||
var resetStyle = 'body { background-color: yellow; color: purple; }'; | ||
insertCss(resetStyle, { prepend: false }); | ||
var reset = colors(); | ||
t.ok(reset.bg === 'rgb(255,255,0)' || reset.bg === 'yellow'); | ||
t.ok(reset.fg === 'rgb(128,0,128)' || reset.fg === 'purple'); | ||
}); | ||
@@ -30,0 +44,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6850
88
54