Skip to content

Commit

Permalink
Clean up AtRule nodes on insert hook
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Dec 15, 2015
1 parent 74ea133 commit b5a4e89
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
10 changes: 0 additions & 10 deletions lib/at-rule.es6
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@ export default class AtRule extends Container {
return super.prepend(...children);
}

insertBefore(exist, add) {
if ( !this.nodes ) this.nodes = [];
return super.insertBefore(exist, add);
}

insertAfter(exist, add) {
if ( !this.nodes ) this.nodes = [];
return super.insertAfter(exist, add);
}

/* istanbul ignore next */
get afterName() {
warnOnce('AtRule#afterName was deprecated. Use AtRule#raws.afterName');
Expand Down
24 changes: 24 additions & 0 deletions test/at-rule.es6
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,30 @@ describe('AtRule', () => {
expect(rule.toString()).to.eql('@encoding "utf-8"');
});

describe('prepend()', () => {

it('creates nodes property', () => {
let rule = new AtRule();
expect(rule.nodes).to.not.exist;

rule.prepend('color: black');
expect(rule.nodes).to.have.length(1);
});

});

describe('append()', () => {

it('creates nodes property', () => {
let rule = new AtRule();
expect(rule.nodes).to.not.exist;

rule.append('color: black');
expect(rule.nodes).to.have.length(1);
});

});

describe('toString()', () => {

it('inserts default spaces', () => {
Expand Down

0 comments on commit b5a4e89

Please sign in to comment.