Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #40 from alanhogan/fix-extends-pseudo

  • Loading branch information...
commit a758afcff9f9da5f05d79b47235a82ca90a0cbc5 2 parents 396b85c + b880036
@kneath authored
Showing with 12 additions and 5 deletions.
  1. +10 −3 example/public/javascripts/kss.js
  2. +2 −2 lib/kss.coffee
View
13 example/public/javascripts/kss.js
@@ -1,6 +1,8 @@
(function() {
var KssStateGenerator;
+
KssStateGenerator = (function() {
+
function KssStateGenerator() {
var idx, idxs, pseudos, replaceRule, rule, stylesheet, _i, _len, _len2, _ref, _ref2;
pseudos = /(\:hover|\:disabled|\:active|\:visited|\:focus)/g;
@@ -12,16 +14,17 @@
_ref2 = stylesheet.cssRules;
for (idx = 0, _len2 = _ref2.length; idx < _len2; idx++) {
rule = _ref2[idx];
- if ((rule.type === CSSRule.STYLE_RULE) && pseudos.test(rule.selectorText)) {
+ while ((rule.type === CSSRule.STYLE_RULE) && pseudos.test(rule.selectorText)) {
replaceRule = function(matched, stuff) {
- return ".pseudo-class-" + matched.replace(':', '');
+ return matched.replace(/\:/g, '.pseudo-class-');
};
this.insertRule(rule.cssText.replace(pseudos, replaceRule));
}
}
}
- } catch (_e) {}
+ } catch (_error) {}
}
+
KssStateGenerator.prototype.insertRule = function(rule) {
var headEl, styleEl;
headEl = document.getElementsByTagName('head')[0];
@@ -34,7 +37,11 @@
}
return headEl.appendChild(styleEl);
};
+
return KssStateGenerator;
+
})();
+
new KssStateGenerator;
+
}).call(this);
View
4 lib/kss.coffee
@@ -15,9 +15,9 @@ class KssStateGenerator
for stylesheet in document.styleSheets
idxs = []
for rule, idx in stylesheet.cssRules
- if (rule.type == CSSRule.STYLE_RULE) && pseudos.test(rule.selectorText)
+ while (rule.type == CSSRule.STYLE_RULE) && pseudos.test(rule.selectorText)
replaceRule = (matched, stuff) ->
- return ".pseudo-class-" + matched.replace(':', '')
+ return matched.replace(/\:/g, '.pseudo-class-')
@insertRule(rule.cssText.replace(pseudos, replaceRule))
# Takes a given style and attaches it to the current page.
Please sign in to comment.
Something went wrong with that request. Please try again.