Permalink
Browse files

refactor

  • Loading branch information...
1 parent 74450e6 commit 1ba7a6085fba2b4b96592660f3fad7296b1eaea4 @tj tj committed Mar 13, 2013
Showing with 11 additions and 6 deletions.
  1. +11 −6 lib/plugins/extend.js
View
@@ -11,20 +11,25 @@ var debug = require('debug')('rework:extend');
module.exports = function() {
debug('use extend');
return function(style, rework) {
- var map = {},
- rules = style.rules.length,
- j = 0;
- for (j; j < rules; j++) {
+ var map = {};
+ var rules = style.rules.length;
+
+ for (var j = 0; j < rules; j++) {
var rule = style.rules[j];
if (!rule || !rule.selectors) return;
+
+ // map selectors
rule.selectors.forEach(function(sel, i) {
map[sel] = rule;
if ('%' == sel[0]) rule.selectors.splice(i, 1);
});
+
+ // visit extend: properties
visit(rule, map);
+
+ // clean up empty rules
if (!rule.declarations.length) {
- style.rules.splice(j, 1);
- j--;
+ style.rules.splice(j--, 1);
}
};
}

0 comments on commit 1ba7a60

Please sign in to comment.