;(function(exports){
var UNDEF = {undefined:1}
var SheetParser = UNDEF[typeof require]
? exports.SheetParser
: require('./SheetParser.CSS').SheetParser
exports.Sheet = Sheet
Sheet.version = '1.0.2 dev'
function Sheet(cssText){
if (this instanceof Sheet) this.initialize(cssText)
else return Sheet.from(cssText)
}
Sheet.from = function(cssText){
return new Sheet(cssText)
}
Sheet.prototype = {
parser: SheetParser.CSS,
initialize: function(cssText){
this.cssText = cssText || ''
this.style = this.rules = this.cssRules = this.parser.parse(this.cssText)
var self = this
},
update: function(){
var cssText = '',
i = -1,
rule,
rules = this.style || this.rules || this.cssRules
while ((rule = rules[++i])){
if (typeof rule == 'object'){
cssRule
if (this.update) rule.cssText = this.update.call(rule)
cssText += rule.cssText = rule.selectorText + '{' + rule.cssText + '}'
} else {
style key/value
cssText += rule + ':'
cssText += rules[rule] + ';'
}
}
if (rules.selectorText)
return rules.cssText = rules.selectorText + '{' + cssText + '}'
return rules.cssText = cssText
}
}
Sheet.prototype.toString = Sheet.prototype.update
}(typeof exports != 'undefined' ? exports : this));