Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

insert-css

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

insert-css - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

8

index.js
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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc