cssom-papandreou
Advanced tools
Comparing version 0.2.3-patch1 to 0.2.3-patch2
//.CommonJS | ||
var CSSOM = { | ||
StyleSheet: require("./StyleSheet").StyleSheet, | ||
CSSStyleRule: require("./CSSStyleRule").CSSStyleRule | ||
CSSStyleRule: require("./CSSStyleRule").CSSStyleRule, | ||
CSSRule: require("./CSSRule").CSSRule | ||
}; | ||
@@ -77,3 +78,3 @@ ///CommonJS | ||
for (var i=0; i<rules.length; i++) { | ||
if (rules[i].type === 1) { | ||
if (rules[i].type === CSSOM.CSSRule.STYLE_RULE) { // STYLE_RULE | ||
result += rules[i].selectorText + " {"; | ||
@@ -83,3 +84,3 @@ if (rules[i].style) { | ||
} | ||
while (i + 1 < rules.length && 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) { | ||
i += 1; | ||
@@ -91,2 +92,17 @@ if (rules[i].style) { | ||
result += "}\n"; | ||
} else if (rules[i].type === CSSOM.CSSRule.FONT_FACE_RULE) { | ||
result += "@font-face {"; | ||
if (rules[i].style) { | ||
result += rules[i].style.cssText; | ||
} | ||
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) { | ||
i += 1; | ||
if (rules[i].style) { | ||
rules[i].style.removeProperty('font-family'); | ||
result += " " + rules[i].style.cssText; | ||
rules[i].style.setProperty('font-family', fontFamily); | ||
} | ||
} | ||
result += "}\n"; | ||
} else { | ||
@@ -93,0 +109,0 @@ result += rules[i].cssText + "\n"; |
//.CommonJS | ||
var CSSOM = { | ||
CSSStyleSheet: require("./CSSStyleSheet").CSSStyleSheet, | ||
CSSRule: require("./CSSRule").CSSRule, | ||
CSSStyleRule: require("./CSSStyleRule").CSSStyleRule, | ||
@@ -243,5 +244,13 @@ CSSImportRule: require("./CSSImportRule").CSSImportRule, | ||
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.selectorText = currentScope.cssRules[currentScope.cssRules.length - 1].selectorText; | ||
} else if (styleRule.type === CSSOM.CSSRule.FONT_FACE_RULE) { | ||
var fontFamily = styleRule.style.getPropertyValue('font-family'); | ||
if (fontFamily) { | ||
newStyleRule.style.setProperty('font-family', fontFamily); | ||
} | ||
} | ||
styleRule = newStyleRule; | ||
} | ||
@@ -248,0 +257,0 @@ styleRule.style.setProperty(name, buffer.trim(), priority); |
@@ -5,3 +5,3 @@ { | ||
"keywords": ["CSS", "CSSOM", "parser", "styleSheet"], | ||
"version": "0.2.3-patch1", | ||
"version": "0.2.3-patch2", | ||
"homepage": "https://github.com/NV/CSSOM", | ||
@@ -8,0 +8,0 @@ "author": "Nikita Vasilyev <me@elv1s.ru>", |
32824
1125
17