mirror of
https://github.com/hanzoai/postcss.git
synced 2026-09-24 17:01:56 +00:00
Add Conrainer#removeAll()
This commit is contained in:
@@ -297,6 +297,18 @@ class Container extends Node {
|
||||
return this;
|
||||
}
|
||||
|
||||
// Remove all children in node.
|
||||
//
|
||||
// css.removeAll();
|
||||
removeAll() {
|
||||
for ( var i = 0; i < this.nodes.length; i++ ) {
|
||||
this.nodes[i].parent == undefined;
|
||||
}
|
||||
this.nodes = [];
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// Return true if all nodes return true in `condition`.
|
||||
// Just shorcut for `nodes.every`.
|
||||
every(condition) {
|
||||
|
||||
@@ -493,6 +493,15 @@ describe('Container', () => {
|
||||
|
||||
});
|
||||
|
||||
describe('removeAll()', () => {
|
||||
|
||||
it('removes all children', () => {
|
||||
this.rule.removeAll();
|
||||
expect(this.rule.toString()).to.eql('a { }');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('any()', () => {
|
||||
|
||||
it('return true if all children return true', () => {
|
||||
|
||||
Reference in New Issue
Block a user