New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cssom-papandreou

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cssom-papandreou - npm Package Compare versions

Comparing version 0.2.6-patch1 to 0.3.0-patch1

6

lib/clone.js

@@ -21,3 +21,3 @@ //.CommonJS

var cloned = new CSSOM.CSSStyleSheet;
var cloned = new CSSOM.CSSStyleSheet();

@@ -41,7 +41,7 @@ var rules = stylesheet.cssRules;

var rule = rules[i];
var ruleClone = cloned.cssRules[i] = new RULE_TYPES[rule.type];
var ruleClone = cloned.cssRules[i] = new RULE_TYPES[rule.type]();
var style = rule.style;
if (style) {
var styleClone = ruleClone.style = new CSSOM.CSSStyleDeclaration;
var styleClone = ruleClone.style = new CSSOM.CSSStyleDeclaration();
for (var j=0, styleLength=style.length; j < styleLength; j++) {

@@ -48,0 +48,0 @@ var name = styleClone[j] = style[j];

@@ -15,7 +15,7 @@ //.CommonJS

CSSOM.CSSRule.call(this);
this.matcher = new CSSOM.MatcherList;
this.matcher = new CSSOM.MatcherList();
this.cssRules = [];
};
CSSOM.CSSDocumentRule.prototype = new CSSOM.CSSRule;
CSSOM.CSSDocumentRule.prototype = new CSSOM.CSSRule();
CSSOM.CSSDocumentRule.prototype.constructor = CSSOM.CSSDocumentRule;

@@ -22,0 +22,0 @@ CSSOM.CSSDocumentRule.prototype.type = 10;

@@ -15,7 +15,7 @@ //.CommonJS

CSSOM.CSSRule.call(this);
this.style = new CSSOM.CSSStyleDeclaration;
this.style = new CSSOM.CSSStyleDeclaration();
this.style.parentRule = this;
};
CSSOM.CSSFontFaceRule.prototype = new CSSOM.CSSRule;
CSSOM.CSSFontFaceRule.prototype = new CSSOM.CSSRule();
CSSOM.CSSFontFaceRule.prototype.constructor = CSSOM.CSSFontFaceRule;

@@ -22,0 +22,0 @@ CSSOM.CSSFontFaceRule.prototype.type = 5;

@@ -18,7 +18,7 @@ //.CommonJS

this.href = "";
this.media = new CSSOM.MediaList;
this.styleSheet = new CSSOM.CSSStyleSheet;
this.media = new CSSOM.MediaList();
this.styleSheet = new CSSOM.CSSStyleSheet();
};
CSSOM.CSSImportRule.prototype = new CSSOM.CSSRule;
CSSOM.CSSImportRule.prototype = new CSSOM.CSSRule();
CSSOM.CSSImportRule.prototype.constructor = CSSOM.CSSImportRule;

@@ -46,4 +46,3 @@ CSSOM.CSSImportRule.prototype.type = 3;

var index;
var mediaText = '';
for (var character; character = cssText.charAt(i); i++) {
for (var character; (character = cssText.charAt(i)); i++) {

@@ -50,0 +49,0 @@ switch (character) {

@@ -16,7 +16,7 @@ //.CommonJS

this.keyText = '';
this.style = new CSSOM.CSSStyleDeclaration;
this.style = new CSSOM.CSSStyleDeclaration();
this.style.parentRule = this;
};
CSSOM.CSSKeyframeRule.prototype = new CSSOM.CSSRule;
CSSOM.CSSKeyframeRule.prototype = new CSSOM.CSSRule();
CSSOM.CSSKeyframeRule.prototype.constructor = CSSOM.CSSKeyframeRule;

@@ -23,0 +23,0 @@ CSSOM.CSSKeyframeRule.prototype.type = 9;

@@ -18,3 +18,3 @@ //.CommonJS

CSSOM.CSSKeyframesRule.prototype = new CSSOM.CSSRule;
CSSOM.CSSKeyframesRule.prototype = new CSSOM.CSSRule();
CSSOM.CSSKeyframesRule.prototype.constructor = CSSOM.CSSKeyframesRule;

@@ -21,0 +21,0 @@ CSSOM.CSSKeyframesRule.prototype.type = 8;

@@ -16,7 +16,7 @@ //.CommonJS

CSSOM.CSSRule.call(this);
this.media = new CSSOM.MediaList;
this.media = new CSSOM.MediaList();
this.cssRules = [];
};
CSSOM.CSSMediaRule.prototype = new CSSOM.CSSRule;
CSSOM.CSSMediaRule.prototype = new CSSOM.CSSRule();
CSSOM.CSSMediaRule.prototype.constructor = CSSOM.CSSMediaRule;

@@ -23,0 +23,0 @@ CSSOM.CSSMediaRule.prototype.type = 4;

@@ -126,3 +126,3 @@ //.CommonJS

set cssText(cssText){
set cssText(text){
var i, name;

@@ -136,3 +136,3 @@ for (i = this.length; i--;) {

var dummyRule = CSSOM.parse('#bogus{' + cssText + '}').cssRules[0].style;
var dummyRule = CSSOM.parse('#bogus{' + text + '}').cssRules[0].style;
var length = dummyRule.length;

@@ -139,0 +139,0 @@ for (i = 0; i < length; ++i) {

@@ -17,7 +17,7 @@ //.CommonJS

this.selectorText = "";
this.style = new CSSOM.CSSStyleDeclaration;
this.style = new CSSOM.CSSStyleDeclaration();
this.style.parentRule = this;
};
CSSOM.CSSStyleRule.prototype = new CSSOM.CSSRule;
CSSOM.CSSStyleRule.prototype = new CSSOM.CSSRule();
CSSOM.CSSStyleRule.prototype.constructor = CSSOM.CSSStyleRule;

@@ -62,6 +62,6 @@ CSSOM.CSSStyleRule.prototype.type = 1;

var styleRule = new CSSOM.CSSStyleRule;
var selector, name, value, priority="";
var styleRule = new CSSOM.CSSStyleRule();
var name, priority="";
for (var character; character = ruleText.charAt(i); i++) {
for (var character; (character = ruleText.charAt(i)); i++) {

@@ -68,0 +68,0 @@ switch (character) {

@@ -20,3 +20,3 @@ //.CommonJS

CSSOM.CSSStyleSheet.prototype = new CSSOM.StyleSheet;
CSSOM.CSSStyleSheet.prototype = new CSSOM.StyleSheet();
CSSOM.CSSStyleSheet.prototype.constructor = CSSOM.CSSStyleSheet;

@@ -46,2 +46,3 @@

var cssRule = CSSOM.parse(rule).cssRules[0];
cssRule.parentStyleSheet = this;
this.cssRules.splice(index, 0, cssRule);

@@ -80,2 +81,16 @@ return index;

var rules = this.cssRules;
function serializeRuleBodyWithoutIsContinuation(cssRule) {
var isContinuation = cssRule.style.getPropertyValue('is-continuation');
result;
if (isContinuation) {
rules[i].style.removeProperty('is-continuation');
}
result = cssRule.style.cssText;
if (isContinuation) {
rules[i].style.setProperty('is-continuation', isContinuation);
}
return result;
}
for (var i=0; i<rules.length; i++) {

@@ -85,9 +100,7 @@ if (rules[i].type === CSSOM.CSSRule.STYLE_RULE) { // STYLE_RULE

if (rules[i].style) {
result += rules[i].style.cssText;
result += serializeRuleBodyWithoutIsContinuation(rules[i]);
}
while (i + 1 < rules.length && rules[i + 1].type === CSSOM.CSSRule.STYLE_RULE && rules[i + 1].selectorText === rules[i].selectorText) {
while (i + 1 < rules.length && rules[i + 1].type === CSSOM.CSSRule.STYLE_RULE && rules[i + 1].selectorText === rules[i].selectorText && rules[i + 1].style && rules[i + 1].style.getPropertyValue('is-continuation') === 'yes') {
i += 1;
if (rules[i].style) {
result += " " + rules[i].style.cssText;
}
result += " " + serializeRuleBodyWithoutIsContinuation(rules[i]);
}

@@ -98,10 +111,10 @@ result += "}\n";

if (rules[i].style) {
result += rules[i].style.cssText;
result += serializeRuleBodyWithoutIsContinuation(rules[i]);
}
var fontFamily = rules[i].style.getPropertyValue('font-family');
while (fontFamily && i + 1 < rules.length && rules[i + 1].type === CSSOM.CSSRule.FONT_FACE_RULE && rules[i + 1].style.getPropertyValue('font-family') === fontFamily) {
while (fontFamily && i + 1 < rules.length && rules[i + 1].type === CSSOM.CSSRule.FONT_FACE_RULE && rules[i + 1].style && rules[i + 1].style.getPropertyValue('is-continuation') === 'yes' && rules[i + 1].style.getPropertyValue('font-family') === fontFamily) {
i += 1;
if (rules[i].style) {
rules[i].style.removeProperty('font-family');
result += " " + rules[i].style.cssText;
result += " " + serializeRuleBodyWithoutIsContinuation(rules[i]);
rules[i].style.setProperty('font-family', fontFamily);

@@ -108,0 +121,0 @@ }

@@ -22,3 +22,3 @@ //.CommonJS

throw new Exception('DOMException: property "cssText" of "' + name + '" is readonly!');
throw new Error('DOMException: property "cssText" of "' + name + '" is readonly and can not be replaced with "' + text + '"!');
},

@@ -29,3 +29,3 @@

throw new Exception('getter "cssText" of "' + name + '" is not implemented!');
throw new Error('getter "cssText" of "' + name + '" is not implemented!');
},

@@ -32,0 +32,0 @@

@@ -18,3 +18,3 @@ //.CommonJS

CSSOM.CSSValueExpression.prototype = new CSSOM.CSSValue;
CSSOM.CSSValueExpression.prototype = new CSSOM.CSSValue();
CSSOM.CSSValueExpression.prototype.constructor = CSSOM.CSSValueExpression;

@@ -26,6 +26,6 @@

* @return {Object}
* - error:
* or
* - idx:
* - expression:
* - error:
* or
* - idx:
* - expression:
*

@@ -53,3 +53,3 @@ * Example:

// end of token
if (character == '') {
if (character === '') {
error = 'css expression error: unfinished expression!';

@@ -71,3 +71,3 @@ break;

case '/':
if (info = this._parseJSComment(token, idx)) { // comment?
if ((info = this._parseJSComment(token, idx))) { // comment?
if (info.error) {

@@ -79,3 +79,3 @@ error = 'css expression error: unfinished comment in expression!';

}
} else if (info = this._parseJSRexExp(token, idx)) { // regexp
} else if ((info = this._parseJSRexExp(token, idx))) { // regexp
idx = info.idx;

@@ -109,3 +109,3 @@ expression += info.text;

// end of expression
if (paren.length == 0) {
if (paren.length === 0) {
break;

@@ -119,3 +119,3 @@ }

error: error
}
};
} else {

@@ -125,3 +125,3 @@ ret = {

expression: expression
}
};
}

@@ -148,3 +148,3 @@

if (nextChar == '/' || nextChar == '*') {
if (nextChar === '/' || nextChar === '*') {
var startIdx = idx,

@@ -154,5 +154,5 @@ endIdx,

if (nextChar == '/') { // line comment
if (nextChar === '/') { // line comment
commentEndChar = '\n';
} else if (nextChar == '*') { // block comment
} else if (nextChar === '*') { // block comment
commentEndChar = '*/';

@@ -168,8 +168,8 @@ }

text: text
}
};
} else {
error = 'css expression error: unfinished comment in expression!';
var error = 'css expression error: unfinished comment in expression!';
return {
error: error
}
};
}

@@ -203,3 +203,3 @@ } else {

text: text
}
};
}

@@ -213,6 +213,6 @@ };

* @return {Object|false}
* - idx:
* - regExp:
* or
* false
* - idx:
* - regExp:
* or
* false
*/

@@ -263,3 +263,3 @@

instanceof /a/
new /a/
new /a/
typeof /a/

@@ -283,3 +283,3 @@ void /a/

/\>$/,
/\<$/,
/<$/,
/\&$/,

@@ -296,3 +296,3 @@ /\|$/,

/typeof$/,
/void$/,
/void$/
];

@@ -337,3 +337,3 @@

matched = text.match(/\\+$/);
if (!matched || matched[0] % 2 == 0) { // not escaped
if (!matched || matched[0] % 2 === 0) { // not escaped
break;

@@ -354,3 +354,3 @@ } else {

return endIdx;
}
};

@@ -357,0 +357,0 @@

@@ -10,3 +10,2 @@ //.CommonJS

CSSOM.parse = function parse(token) {
var i = 0;

@@ -39,3 +38,3 @@

var styleSheet = new CSSOM.CSSStyleSheet;
var styleSheet = new CSSOM.CSSStyleSheet();

@@ -48,3 +47,3 @@ // @type CSSStyleSheet|CSSMediaRule|CSSFontFaceRule|CSSKeyframesRule|CSSDocumentRule

var selector, name, value, priority="", styleRule, mediaRule, importRule, fontFaceRule, keyframesRule, keyframeRule, documentRule;
var name, priority="", styleRule, mediaRule, importRule, fontFaceRule, keyframesRule, documentRule;

@@ -59,3 +58,4 @@ var atKeyframesRegExp = /@(-(?:\w+-)+)?keyframes/g;

error.line = lineCount;
error.char = charCount;
/* jshint sub : true */
error['char'] = charCount;
error.styleSheet = styleSheet;

@@ -65,3 +65,3 @@ throw error;

for (var character; character = token.charAt(i); i++) {
for (var character; (character = token.charAt(i)); i++) {

@@ -88,3 +88,3 @@ switch (character) {

}
} while (token[index - 2] === '\\')
} while (token[index - 2] === '\\');
buffer += token.slice(i, index);

@@ -109,3 +109,3 @@ i = index - 1;

}
} while (token[index - 2] === '\\')
} while (token[index - 2] === '\\');
buffer += token.slice(i, index);

@@ -146,3 +146,3 @@ i = index - 1;

state = "documentRule-begin";
documentRule = new CSSOM.CSSDocumentRule;
documentRule = new CSSOM.CSSDocumentRule();
documentRule.__starts = i;

@@ -154,3 +154,3 @@ i += "-moz-document".length;

state = "atBlock";
mediaRule = new CSSOM.CSSMediaRule;
mediaRule = new CSSOM.CSSMediaRule();
mediaRule.__starts = i;

@@ -168,3 +168,3 @@ i += "media".length;

i += "font-face".length;
fontFaceRule = new CSSOM.CSSFontFaceRule;
fontFaceRule = new CSSOM.CSSFontFaceRule();
fontFaceRule.__starts = i;

@@ -178,3 +178,3 @@ buffer = "";

state = "keyframesRule-begin";
keyframesRule = new CSSOM.CSSKeyframesRule;
keyframesRule = new CSSOM.CSSKeyframesRule();
keyframesRule.__starts = i;

@@ -185,3 +185,3 @@ keyframesRule._vendorPrefix = matchKeyframes[1]; // Will come out as undefined if no prefix was found

break;
} else if (state == "selector") {
} else if (state === "selector") {
state = "atRule";

@@ -223,3 +223,3 @@ }

} else if (state === "keyframeRule-begin") {
styleRule = new CSSOM.CSSKeyframeRule;
styleRule = new CSSOM.CSSKeyframeRule();
styleRule.keyText = buffer.trim();

@@ -255,3 +255,3 @@ styleRule.__starts = i;

// ie css expression mode
if (buffer.trim() == 'expression') {
if (buffer.trim() === 'expression') {
var info = (new CSSOM.CSSValueExpression(token, i)).parse();

@@ -293,2 +293,3 @@

// Temporary workaround until https://github.com/NV/CSSOM/issues/16 gets resolved
// Remember to keep this block of code in sync with the equivalent hack 50 lines below.
if (styleRule.style.getPropertyValue(name)) {

@@ -299,5 +300,7 @@ styleRule.__ends = i;

newStyleRule.__starts = i;
if (styleRule.type === CSSOM.CSSRule.STYLE_RULE) {
if (styleRule.type === CSSOM.CSSRule.STYLE_RULE) {
newStyleRule.style.setProperty('is-continuation', 'yes');
newStyleRule.selectorText = currentScope.cssRules[currentScope.cssRules.length - 1].selectorText;
} else if (styleRule.type === CSSOM.CSSRule.FONT_FACE_RULE) {
newStyleRule.style.setProperty('is-continuation', 'yes');
var fontFamily = styleRule.style.getPropertyValue('font-family');

@@ -320,3 +323,3 @@ if (fontFamily) {

case "importRule":
importRule = new CSSOM.CSSImportRule;
importRule = new CSSOM.CSSImportRule();
importRule.parentStyleSheet = importRule.styleSheet.parentStyleSheet = styleSheet;

@@ -339,11 +342,23 @@ importRule.cssText = buffer + character;

// Temporary workaround until https://github.com/NV/CSSOM/issues/16 gets resolved
// Remember to keep this block of code in sync with the equivalent hack 50 lines above.
if (styleRule.style.getPropertyValue(name)) {
styleRule.__ends = i;
currentScope.cssRules.push(styleRule);
styleRule = new CSSOM.CSSStyleRule;
styleRule.selectorText = currentScope.cssRules[currentScope.cssRules.length - 1].selectorText;
styleRule.__starts = i;
var newStyleRule = new styleRule.constructor();
newStyleRule.__starts = i;
if (styleRule.type === CSSOM.CSSRule.STYLE_RULE) {
newStyleRule.style.setProperty('is-continuation', 'yes');
newStyleRule.selectorText = currentScope.cssRules[currentScope.cssRules.length - 1].selectorText;
} else if (styleRule.type === CSSOM.CSSRule.FONT_FACE_RULE) {
newStyleRule.style.setProperty('is-continuation', 'yes');
var fontFamily = styleRule.style.getPropertyValue('font-family');
if (fontFamily) {
newStyleRule.style.setProperty('font-family', fontFamily);
}
}
styleRule = newStyleRule;
}
styleRule.style.setProperty(name, buffer.trim(), priority);
priority = "";
/* falls through */
case "before-name":

@@ -386,3 +401,3 @@ case "name":

state = "selector";
styleRule = new CSSOM.CSSStyleRule;
styleRule = new CSSOM.CSSStyleRule();
styleRule.__starts = i;

@@ -389,0 +404,0 @@ break;

{
"name": "cssom-papandreou",
"description": "CSS Object Model implementation and CSS parser (fork that hacks in support for multiple occurrences of the same CSS property in a rule)",
"description": "CSS Object Model implementation and CSS parser",
"keywords": ["CSS", "CSSOM", "parser", "styleSheet"],
"version": "0.2.6-patch1",
"version": "0.3.0-patch1",
"homepage": "https://github.com/NV/CSSOM",

@@ -12,18 +12,11 @@ "author": "Nikita Vasilyev <me@elv1s.ru>",

},
"directories": {
"lib": "./lib"
},
"bugs": "https://github.com/papandreou/CSSOM/issues",
"main": "./lib/index.js",
"engines": {
"node": ">=0.2.0"
},
"devDependencies": {
"jake": "0.2.x"
"jake": "~0.7.3"
},
"licenses": [
{
"type": "MIT",
"url": "http://creativecommons.org/licenses/MIT/"
}
],
"license": {
"type": "MIT",
"url": "http://creativecommons.org/licenses/MIT/"
},
"scripts": {

@@ -30,0 +23,0 @@ "prepublish": "jake lib/index.js"

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