Skip to content

Commit

Permalink
Correctly set parentStyleSheet on inserted rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Burgmer authored and domenic committed Nov 9, 2013
1 parent a60ddf4 commit 6ad515e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/CSSStyleSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ CSSOM.CSSStyleSheet.prototype.insertRule = function(rule, index) {
throw new RangeError("INDEX_SIZE_ERR");
}
var cssRule = CSSOM.parse(rule).cssRules[0];
cssRule.parentStyleSheet = this;
this.cssRules.splice(index, 0, cssRule);
return index;
};
Expand Down
7 changes: 7 additions & 0 deletions spec/CSSStyleSheet.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,12 @@ describe('CSSStyleSheet', function() {
expect(s.cssRules).toEqual([]);
});

describe('insertRule', function () {
it('should correctly set the parent stylesheet', function () {
var s = new CSSOM.CSSStyleSheet;
s.insertRule("a {color: blue}", 0);
expect(s.cssRules[0].parentStyleSheet).toBe(s);
});
});
});
});

0 comments on commit 6ad515e

Please sign in to comment.