You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

cssstylesheet

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cssstylesheet - npm Package Compare versions

Comparing version

to
0.2.0

30

build/cssstylesheet.js

@@ -67,4 +67,6 @@ /*!

var CSSStyleSheet;
var cssRulesName = ('cssRules' in cssss.prototype) ? 'cssRules' : 'rules';
var CSSStyleSheet, cssRulesName;
if ('createStyleSheet' in document) {

@@ -77,7 +79,4 @@ /**

CSSStyleSheet = function CSSStyleSheet() {
this._element = document.createStyleSheet();
head.appendChild(this._element);
this._sheet = this._element.sheet;
this._element = null;
this._sheet = document.createStyleSheet();
};

@@ -104,3 +103,3 @@ } else {

CSSStyleSheet.prototype.insertRule = ('insertRule' in cssss) ?
CSSStyleSheet.prototype.insertRule = ('insertRule' in cssss.prototype) ?
/**

@@ -129,3 +128,3 @@ * insert rule for modern browsers

CSSStyleSheet.prototype.deleteRule = ('deleteRule' in cssss) ?
CSSStyleSheet.prototype.deleteRule = ('deleteRule' in cssss.prototype) ?
/**

@@ -156,3 +155,3 @@ * delete rule for modern browsers

CSSStyleSheet.prototype.addRule = function addRule(selector, ruleText) {
var length = this._sheet.rules.length;
var length = this._sheet[cssRulesName].length;

@@ -166,3 +165,3 @@ return this.insertRule(selector, ruleText, length);

CSSStyleSheet.prototype.clearRule = function clearRule() {
var i = this._sheet.rules.length;
var i = this._sheet[cssRulesName].length;

@@ -179,3 +178,3 @@ while (i--) {

*
* @return {HTMLStyleElement}
* @return {Null|HTMLStyleElement}
*/

@@ -195,2 +194,11 @@ CSSStyleSheet.prototype.getElement = function getElement() {

/**
* get rules
*
* @return {CSSRuleList}
*/
CSSStyleSheet.prototype.getRules = function getRules() {
return this._sheet[cssRulesName];
}
//------------------------------------------------------------------------------

@@ -197,0 +205,0 @@

@@ -6,2 +6,2 @@ /*!

*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.cssstylesheet=t():e.cssstylesheet=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t){"use strict";var n,r=document.getElementsByTagName("head")[0],o=window.CSSStyleSheet;n="createStyleSheet"in document?function(){this._element=document.createStyleSheet(),r.appendChild(this._element),this._sheet=this._element.sheet}:function(){this._element=document.createElement("style"),this._element.appendChild(document.createTextNode("")),r.appendChild(this._element),this._sheet=this._element.sheet},n.prototype.insertRule="insertRule"in o?function(e,t,n){return this._sheet.insertRule(e+"{"+t+"}",n)}:function(e,t,n){return this._sheet.addRule(e,t,n)},n.prototype.deleteRule="deleteRule"in o?function(e){return this._sheet.deleteRule(e)}:function(e){return this._sheet.removeRule(e)},n.prototype.addRule=function(e,t){var n=this._sheet.rules.length;return this.insertRule(e,t,n)},n.prototype.clearRule=function(){for(var e=this._sheet.rules.length;e--;)this.deleteRule(e)},n.prototype.getElement=function(){return this._element},n.prototype.getSheet=function(){return this._sheet},n.create=function(){return new n},e.exports=n}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.cssstylesheet=t():e.cssstylesheet=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t){"use strict";var n,o,r=document.getElementsByTagName("head")[0],s=window.CSSStyleSheet,o="cssRules"in s.prototype?"cssRules":"rules";n="createStyleSheet"in document?function(){this._element=null,this._sheet=document.createStyleSheet()}:function(){this._element=document.createElement("style"),this._element.appendChild(document.createTextNode("")),r.appendChild(this._element),this._sheet=this._element.sheet},n.prototype.insertRule="insertRule"in s.prototype?function(e,t,n){return this._sheet.insertRule(e+"{"+t+"}",n)}:function(e,t,n){return this._sheet.addRule(e,t,n)},n.prototype.deleteRule="deleteRule"in s.prototype?function(e){return this._sheet.deleteRule(e)}:function(e){return this._sheet.removeRule(e)},n.prototype.addRule=function(e,t){var n=this._sheet[o].length;return this.insertRule(e,t,n)},n.prototype.clearRule=function(){for(var e=this._sheet[o].length;e--;)this.deleteRule(e)},n.prototype.getElement=function(){return this._element},n.prototype.getSheet=function(){return this._sheet},n.prototype.getRules=function(){return this._sheet[o]},n.create=function(){return new n},e.exports=n}])});

@@ -0,3 +1,9 @@

# 0.2.0 / 2016-03-29
- add getRules method
- fix for Internet Explorer
- fix for Firefox
# 0.1.0 / 2016-03-27
- initial release
{
"name": "cssstylesheet",
"version": "0.1.0",
"version": "0.2.0",
"author": "sasa+1 <sasaplus1@gmail.com>",

@@ -18,5 +18,7 @@ "description": "cross browser CSSStyleSheet",

"develop": "parallelshell 'npm ru compile -- -w' 'npm ru minify -- -w'",
"karma": "karma start --colors",
"minify": "npm ru webpack -- --optimize-minimize --output-filename ./build/cssstylesheet.min.js",
"prepublish": "npm ru build",
"rimraf": "rimraf",
"test": "npm ru karma -- --single-run --browsers Firefox,Chrome,Safari",
"webpack": "webpack --colors --display-error-details --progress"

@@ -26,3 +28,10 @@ },

"coffee-script": "^1.10.0",
"karma": "^0.13.22",
"karma-chrome-launcher": "^0.2.3",
"karma-espower-preprocessor": "0.0.4",
"karma-firefox-launcher": "^0.1.7",
"karma-mocha": "^0.2.2",
"karma-safari-launcher": "^0.1.1",
"parallelshell": "^2.0.0",
"power-assert": "^1.3.1",
"rimraf": "^2.5.2",

@@ -29,0 +38,0 @@ "webpack": "^1.12.14"

@@ -17,4 +17,69 @@ # cssstylesheet.js

### Example
```js
var sheet = cssstylesheet.create(); // or sheet = new cssstylesheet();
// add css rule
sheet.addRule('body', 'background-color: #ccccff;');
// remove all
sheet.clearRule();
```
## Functions
### cssstylesheet
cssstylesheet constructor.
### cssstylesheet#insertRule(selector, ruleText, index)
- `selector`
- `String`
- `ruleText`
- `String`
- `index`
- `Number`
insert rule at index.
### cssstylesheet#deleteRule(index)
- `index`
- `Number`
delete rule of index.
### cssstylesheet#addRule(selector, ruleText)
- `selector`
- `String`
- `ruleText`
- `String`
add rule at last.
### cssstylesheet#clearRule()
delete all rule.
### cssstylesheet#getElement()
return HTMLStyleElement, but return null if browser is old IE.
### cssstylesheet#getSheet()
return CSSStyleSheet.
### cssstylesheet#getRules()
return CSSRuleList.
### cssstylesheet.create()
create cssstylesheet instance.
## License
The MIT license. Please see LICENSE file.

@@ -6,4 +6,6 @@ 'use strict';

var CSSStyleSheet;
var cssRulesName = ('cssRules' in cssss.prototype) ? 'cssRules' : 'rules';
var CSSStyleSheet, cssRulesName;
if ('createStyleSheet' in document) {

@@ -16,7 +18,4 @@ /**

CSSStyleSheet = function CSSStyleSheet() {
this._element = document.createStyleSheet();
head.appendChild(this._element);
this._sheet = this._element.sheet;
this._element = null;
this._sheet = document.createStyleSheet();
};

@@ -43,3 +42,3 @@ } else {

CSSStyleSheet.prototype.insertRule = ('insertRule' in cssss) ?
CSSStyleSheet.prototype.insertRule = ('insertRule' in cssss.prototype) ?
/**

@@ -68,3 +67,3 @@ * insert rule for modern browsers

CSSStyleSheet.prototype.deleteRule = ('deleteRule' in cssss) ?
CSSStyleSheet.prototype.deleteRule = ('deleteRule' in cssss.prototype) ?
/**

@@ -95,3 +94,3 @@ * delete rule for modern browsers

CSSStyleSheet.prototype.addRule = function addRule(selector, ruleText) {
var length = this._sheet.rules.length;
var length = this._sheet[cssRulesName].length;

@@ -105,3 +104,3 @@ return this.insertRule(selector, ruleText, length);

CSSStyleSheet.prototype.clearRule = function clearRule() {
var i = this._sheet.rules.length;
var i = this._sheet[cssRulesName].length;

@@ -118,3 +117,3 @@ while (i--) {

*
* @return {HTMLStyleElement}
* @return {Null|HTMLStyleElement}
*/

@@ -134,2 +133,11 @@ CSSStyleSheet.prototype.getElement = function getElement() {

/**
* get rules
*
* @return {CSSRuleList}
*/
CSSStyleSheet.prototype.getRules = function getRules() {
return this._sheet[cssRulesName];
}
//------------------------------------------------------------------------------

@@ -136,0 +144,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.