Skip to content

Commit 7b08500

Browse files
committed
Gonzales 3.0: Update space-before-combinator
1 parent 0528cfc commit 7b08500

2 files changed

Lines changed: 17 additions & 15 deletions

File tree

lib/options/space-before-combinator.js

Lines changed: 10 additions & 8 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-combinator',
35

@@ -13,22 +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-combinator');
2324

2425
for (var i = node.length; i--;) {
25-
var subSelector = node[i];
26+
var subSelector = node.get(i);
2627
for (var j = subSelector.length; j--;) {
27-
if (subSelector[j][0] !== 'combinator') continue;
28-
if (subSelector[j - 1][0] === 's') {
29-
subSelector[j - 1][1] = value;
28+
if (!subSelector.get(j).is('combinator')) continue;
29+
if (subSelector.get(j - 1).is('s')) {
30+
subSelector.get(j - 1).content = value;
3031
} else {
31-
subSelector.splice(j, 0, ['s', value]);
32+
var space = gonzales.createNode({ type: 's', content: value });
33+
subSelector.insert(j, space);
3234
}
3335
}
3436
}

test/options/space-before-combinator/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-combinator:', function() {
1+
describe('options/space-before-combinator:', function() {
22
it('Array value => should not change anything', function() {
33
this.comb.configure({ 'space-before-combinator': ['', ' '] });
44
this.shouldBeEqual('test.css');
@@ -29,47 +29,47 @@ describe.skip('options/space-before-combinator:', function() {
2929
this.shouldBeEqual('test.css', 'test-3.expected.css');
3030
});
3131

32-
it('Should detect no whitespaces before combinator', function() {
32+
it.skip('Should detect no whitespaces before combinator', function() {
3333
this.shouldDetect(
3434
['space-before-combinator'],
3535
'a+b { color:red }',
3636
{ 'space-before-combinator': '' }
3737
);
3838
});
3939

40-
it('Should detect a space before combinator', function() {
40+
it.skip('Should detect a space before combinator', function() {
4141
this.shouldDetect(
4242
['space-before-combinator'],
4343
'a + b { color:red }',
4444
{ 'space-before-combinator': ' ' }
4545
);
4646
});
4747

48-
it('Should detect a space before combinator in long selector', function() {
48+
it.skip('Should detect a space before combinator in long selector', function() {
4949
this.shouldDetect(
5050
['space-before-combinator'],
5151
'a + b ~ c>d { color:red }',
5252
{ 'space-before-combinator': ' ' }
5353
);
5454
});
5555

56-
it('Should detect a space before combinator in long selector, test 2', function() {
56+
it.skip('Should detect a space before combinator in long selector, test 2', function() {
5757
this.shouldDetect(
5858
['space-before-combinator'],
5959
'a>b + c + d { color:red }',
6060
{ 'space-before-combinator': ' ' }
6161
);
6262
});
6363

64-
it('Should detect no whitespaces before combinator in long selector', function() {
64+
it.skip('Should detect no whitespaces before combinator in long selector', function() {
6565
this.shouldDetect(
6666
['space-before-combinator'],
6767
'a+b ~ c+d { color:red }',
6868
{ 'space-before-combinator': '' }
6969
);
7070
});
7171

72-
it('Shouldn’t detect whitespaces before combinator in selector without combinators', function() {
72+
it.skip('Shouldn’t detect whitespaces before combinator in selector without combinators', function() {
7373
this.shouldDetect(
7474
['space-before-combinator'],
7575
'a { color:red }',

0 commit comments

Comments
 (0)