Commit 09148961 authored by Nellie McKesson's avatar Nellie McKesson

a little cleanup

parent cfda8c14
......@@ -5,6 +5,7 @@ import Splits from "./splits";
import Counters from "./counters";
import Lists from "./lists";
import PositionFixed from "./position-fixed";
import NthOfType from "./nth-of-type";
export default [
AtPage,
......@@ -13,5 +14,6 @@ export default [
Splits,
Counters,
Lists,
PositionFixed
PositionFixed,
NthOfType
];
......@@ -13,30 +13,20 @@ class NthOfType extends Handler {
onRule(ruleNode, ruleItem, rulelist) {
let selector = csstree.generate(ruleNode.prelude);
if (selector.match(/:(first|last|nth)-of-type/)) {
// process it
console.log(ruleNode);
console.log(selector);
let declarations = csstree.generate(ruleNode.block);
declarations = declarations.replace(/[{}]/g,"");
console.log("DECLART");
console.log(declarations);
let uuid = UUID();
// does this selector already exist in the hash?
// if yes, just create a new rule using the existing random string.
// if no, create a random string for it and then create the new rule
selector.split(",").forEach((s) => {
if (!this.selectors[s]) {
this.selectors[s] = [uuid, declarations];
// make the new rule
} else {
this.selectors[s][1] = `${this.selectors[s][1]};${declarations}` ;
// make the new rule
// makeRule(this.selectors[s])
}
});
......@@ -52,7 +42,6 @@ class NthOfType extends Handler {
processSelectors(parsed, selectors) {
// add the new attributes to matching elements
for (let s in selectors) {
// Find elements
let elements = parsed.querySelectorAll(s);
for (var i = 0; i < elements.length; i++) {
......@@ -62,7 +51,6 @@ class NthOfType extends Handler {
let rule = `*[data-css-rule='${selectors[s][0]}'] { ${selectors[s][1]}; }`;
this.styleSheet.insertRule(rule, this.styleSheet.cssRules.length);
}
console.log(this.styleSheet);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment