Skip to content

Commit 6ad515e

Browse files
Christoph Burgmerdomenic
authored andcommitted
Correctly set parentStyleSheet on inserted rules
1 parent a60ddf4 commit 6ad515e

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/CSSStyleSheet.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ CSSOM.CSSStyleSheet.prototype.insertRule = function(rule, index) {
4141
throw new RangeError("INDEX_SIZE_ERR");
4242
}
4343
var cssRule = CSSOM.parse(rule).cssRules[0];
44+
cssRule.parentStyleSheet = this;
4445
this.cssRules.splice(index, 0, cssRule);
4546
return index;
4647
};

spec/CSSStyleSheet.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,12 @@ describe('CSSStyleSheet', function() {
1818
expect(s.cssRules).toEqual([]);
1919
});
2020

21+
describe('insertRule', function () {
22+
it('should correctly set the parent stylesheet', function () {
23+
var s = new CSSOM.CSSStyleSheet;
24+
s.insertRule("a {color: blue}", 0);
25+
expect(s.cssRules[0].parentStyleSheet).toBe(s);
26+
});
27+
});
2128
});
2229
});

0 commit comments

Comments
 (0)