Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.

Commit

Permalink
fix multiple selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
aeosynth committed Feb 11, 2011
1 parent 7092127 commit ccae5dd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 8 additions & 2 deletions lib/ccss.js
Expand Up @@ -9,7 +9,7 @@ extend = function(object, properties) {
return object;
};
this.compile = function(rules) {
var css, declarations, key, mixin, mixins, nested, pairs, selector, value, _i, _len, _ref;
var child, children, css, declarations, key, mixin, mixins, nested, pairs, selector, split, value, _i, _j, _len, _len2, _ref;
css = '';
for (selector in rules) {
pairs = rules[selector];
Expand All @@ -26,7 +26,13 @@ this.compile = function(rules) {
for (key in pairs) {
value = pairs[key];
if (typeof value === 'object') {
nested["" + selector + " " + key] = value;
children = [];
split = key.split(/\s*,\s*/);
for (_j = 0, _len2 = split.length; _j < _len2; _j++) {
child = split[_j];
children.push("" + selector + " " + child);
}
nested[children.join(',')] = value;
} else {
key = key.replace(/[A-Z]/g, function(s) {
return '-' + s.toLowerCase();
Expand Down
5 changes: 4 additions & 1 deletion src/ccss.coffee
Expand Up @@ -21,7 +21,10 @@ extend = (object, properties) ->
#a pair is either a css declaration, or a nested rule
for key, value of pairs
if typeof value is 'object'
nested["#{selector} #{key}"] = value
children = []
split = key.split /\s*,\s*/
children.push "#{selector} #{child}" for child in split
nested[children.join ','] = value
else
#borderRadius -> border-radius
key = key.replace /[A-Z]/g, (s) -> '-' + s.toLowerCase()
Expand Down

0 comments on commit ccae5dd

Please sign in to comment.