Skip to content

Commit

Permalink
fixed InvalidAccessError when modifying html
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Jun 9, 2019
1 parent ba5a93b commit ea137dc
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions src/index.jsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
import "resources/nav/index.js"

// https://stackoverflow.com/questions/1409225/changing-a-css-rule-set-from-javascript
function getCSSRule(ruleName) {
ruleName = ruleName.toLowerCase();
var result = null;
var find = Array.prototype.find;

find.call(document.styleSheets, styleSheet => {
result = find.call(styleSheet.cssRules, cssRule => {
return cssRule instanceof CSSStyleRule
&& cssRule.selectorText.toLowerCase() == ruleName;
});
return result != null;
});
return result;
}

class SOGNavPlugin {
initialize(registry, store) {
getCSSRule(".SOGNav__MenuItem").style.margin = "8px";
let elements = document.getElementsByClassName("SOGNav__MenuItem");
for (let i = 0; i < elements.length; i++) {
elements[i].style.margin = "8px";
}
}
}

Expand Down

0 comments on commit ea137dc

Please sign in to comment.