Commit 77b83891 authored by Nellie McKesson's avatar Nellie McKesson

making updates per Freds notes

parent 758d9527
...@@ -17,7 +17,7 @@ class NthOfType extends Handler { ...@@ -17,7 +17,7 @@ class NthOfType extends Handler {
let declarations = csstree.generate(ruleNode.block); let declarations = csstree.generate(ruleNode.block);
declarations = declarations.replace(/[{}]/g,""); declarations = declarations.replace(/[{}]/g,"");
let uuid = UUID(); let uuid = "nth-of-type-" + UUID();
selector.split(",").forEach((s) => { selector.split(",").forEach((s) => {
if (!this.selectors[s]) { if (!this.selectors[s]) {
...@@ -41,17 +41,17 @@ class NthOfType extends Handler { ...@@ -41,17 +41,17 @@ class NthOfType extends Handler {
let elements = parsed.querySelectorAll(s); let elements = parsed.querySelectorAll(s);
for (var i = 0; i < elements.length; i++) { for (var i = 0; i < elements.length; i++) {
let dataCssRule = elements[i].getAttribute("data-css-rule"); let dataNthOfType = elements[i].getAttribute("data-nth-of-type");
if (dataCssRule && dataCssRule != "") { if (dataNthOfType && dataNthOfType != "") {
dataCssRule = `${dataCssRule},${selectors[s][0]}`; dataNthOfType = `${dataNthOfType},${selectors[s][0]}`;
elements[i].setAttribute("data-css-rule", dataCssRule); elements[i].setAttribute("data-nth-of-type", dataNthOfType);
} else { } else {
elements[i].setAttribute("data-css-rule", selectors[s][0]); elements[i].setAttribute("data-nth-of-type", selectors[s][0]);
} }
} }
let rule = `*[data-css-rule*='${selectors[s][0]}'] { ${selectors[s][1]}; }`; let rule = `*[data-nth-of-type*='${selectors[s][0]}'] { ${selectors[s][1]}; }`;
this.styleSheet.insertRule(rule, this.styleSheet.cssRules.length); this.styleSheet.insertRule(rule, this.styleSheet.cssRules.length);
} }
} }
......
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