Skip to content

Commit ced8b94

Browse files
committed
Gonzales 3.0: Update space-before-selector-delimiter
1 parent a1bcd5f commit ced8b94

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

lib/options/space-before-selector-delimiter.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
var gonzales = require('gonzales-pe');
2+
13
module.exports = {
24
name: 'space-before-selector-delimiter',
35

@@ -13,24 +15,22 @@ module.exports = {
1315
/**
1416
* Processes tree node.
1517
*
16-
* @param {String} nodeType
1718
* @param {node} node
1819
*/
19-
process: function(nodeType, node) {
20-
if (nodeType !== 'selector') return;
20+
process: function(node) {
21+
if (!node.is('selector')) return;
2122

2223
var value = this.getValue('space-before-selector-delimiter');
2324

24-
for (var i = node.length; i--;) {
25-
if (node[i][0] !== 'delim') continue;
26-
27-
var previousNode = node[i - 1];
28-
if (previousNode[previousNode.length - 1][0] === 's') {
29-
previousNode[previousNode.length - 1][1] = value;
25+
node.forEach('delim', function(delim, i) {
26+
var previousNode = node.get(i - 1);
27+
if (previousNode.last().is('s')) {
28+
previousNode.last().content = value;
3029
} else {
31-
previousNode.push(['s', value]);
30+
var space = gonzales.createNode({ type: 's', content: value });
31+
previousNode.content.push(space);
3232
}
33-
}
33+
});
3434
},
3535

3636
/**

test/options/space-before-selector-delimiter/test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe.skip('options/space-before-selector-delimiter:', function() {
1+
describe('options/space-before-selector-delimiter:', function() {
22
it('Array value => should not change anything', function() {
33
this.comb.configure({ 'space-before-selector-delimiter': ['', ' '] });
44
this.shouldBeEqual('test.css');
@@ -29,47 +29,47 @@ describe.skip('options/space-before-selector-delimiter:', function() {
2929
this.shouldBeEqual('test.css', 'test-3.expected.css');
3030
});
3131

32-
it('Should detect no whitespace', function() {
32+
it.skip('Should detect no whitespace', function() {
3333
this.shouldDetect(
3434
['space-before-selector-delimiter'],
3535
'a,b{top:0}',
3636
{ 'space-before-selector-delimiter': '' }
3737
);
3838
});
3939

40-
it('Should detect whitespace', function() {
40+
it.skip('Should detect whitespace', function() {
4141
this.shouldDetect(
4242
['space-before-selector-delimiter'],
4343
'a \n ,b {top:0}',
4444
{ 'space-before-selector-delimiter': ' \n ' }
4545
);
4646
});
4747

48-
it('Should detect no whitespace (2 blocks)', function() {
48+
it.skip('Should detect no whitespace (2 blocks)', function() {
4949
this.shouldDetect(
5050
['space-before-selector-delimiter'],
5151
'a,b{top:0} a ,b{left:0}',
5252
{ 'space-before-selector-delimiter': '' }
5353
);
5454
});
5555

56-
it('Should detect whitespace (2 blocks)', function() {
56+
it.skip('Should detect whitespace (2 blocks)', function() {
5757
this.shouldDetect(
5858
['space-before-selector-delimiter'],
5959
'a ,b {top:0} b,a{left:0}',
6060
{ 'space-before-selector-delimiter': ' ' }
6161
);
6262
});
6363

64-
it('Should detect no whitespace (3 blocks)', function() {
64+
it.skip('Should detect no whitespace (3 blocks)', function() {
6565
this.shouldDetect(
6666
['space-before-selector-delimiter'],
6767
'a ,b{top:0} b,c{left:0} c,d{right:0}',
6868
{ 'space-before-selector-delimiter': '' }
6969
);
7070
});
7171

72-
it('Should detect whitespace (3 blocks)', function() {
72+
it.skip('Should detect whitespace (3 blocks)', function() {
7373
this.shouldDetect(
7474
['space-before-selector-delimiter'],
7575
'a,b{top:0} b ,c{left:0} c ,d{right:0}',

0 commit comments

Comments
 (0)