Skip to content

Commit 102a093

Browse files
Update my-css.js
Fix stylesheet.addRule.
1 parent 3ac2e78 commit 102a093

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

my-css.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
/**
23
* @file Direction-free CSS
34
* @author Mahdi NezaratiZadeh <mahdi.nezarati@gmail.com>
@@ -139,14 +140,15 @@ window.MyCSS = {
139140
_addToStyleSheet(selector, declaration)
140141
{
141142
let stylesheet = this._stylesheet;
143+
let index = stylesheet.rules.length;
142144
if (stylesheet.insertRule) {
143145
var inner_code=`${selector} {
144146
${declaration}
145147
}`;
146148
//console.log(inner_code);
147-
return stylesheet.insertRule(inner_code, stylesheet.rules.length);
149+
return stylesheet.insertRule(inner_code,index);
148150
} else if (stylesheet.addRule) {
149-
return stylesheet.addRule(stylesheet, declaration);
151+
return stylesheet.addRule(selector,declaration,index);
150152
} else {
151153
throw new Error('X_0');
152154
}

0 commit comments

Comments
 (0)