Skip to content

Commit

Permalink
fix bug where trim was undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
client9 committed Mar 30, 2010
1 parent 5571a5a commit e9aafd9
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/css/stylesheet.js
@@ -1,38 +1,40 @@

/*
* CSSStyleSheet - DOM Level 2
*/
/*
* CSSStyleSheet - DOM Level 2
*/
CSSStyleSheet = function(options){
var $cssRules,
var $cssRules,
$disabled = options.disabled?options.disabled:false,
$href = options.href?options.href:null,
$parentStyleSheet = options.parentStyleSheet?options.parentStyleSheet:null,
$title = options.title?options.title:"",
$type = "text/css";

function parseStyleSheet(text){
//$debug("parsing css");
//this is pretty ugly, but text is the entire text of a stylesheet
var cssRules = [];
if (!text) text = "";
text = trim(text.replace(/\/\*(\r|\n|.)*\*\//g,""));
if (!text) {
text = "";
}
text = __trim__(text.replace(/\/\*(\r|\n|.)*\*\//g,""));
// TODO: @import ?
var blocks = text.split("}");
blocks.pop();
var i, len = blocks.length;
var i, j, len = blocks.length;
var definition_block, properties, selectors;
for (i=0; i<len; i++){
definition_block = blocks[i].split("{");
if(definition_block.length === 2){
selectors = definition_block[0].split(",");
for(var j=0;j<selectors.length;j++){
cssRules.push(new CSSRule({
selectorText:selectors[j],
cssText:definition_block[1]
}));
}
__setArray__($cssRules, cssRules);
definition_block = blocks[i].split("{");
if(definition_block.length === 2){
selectors = definition_block[0].split(",");
for(j=0;j<selectors.length;j++){
cssRules.push(new CSSRule({
selectorText:selectors[j],
cssText:definition_block[1]
}));
}
__setArray__($cssRules, cssRules);
}
}
};
parseStyleSheet(options.text);
Expand Down Expand Up @@ -64,5 +66,3 @@ CSSStyleSheet = function(options){
}
});
};


0 comments on commit e9aafd9

Please sign in to comment.