Skip to content

Commit 010d399

Browse files
committed
Gonzales 3.0: Update space-after-selector-delimiter
1 parent 8b67eaf commit 010d399

3 files changed

Lines changed: 20 additions & 18 deletions

File tree

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

Lines changed: 12 additions & 10 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-after-selector-delimiter',
35

@@ -13,23 +15,23 @@ 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-after-selector-delimiter');
2324

24-
for (var i = node.length; i--;) {
25-
if (node[i][0] !== 'delim') continue;
25+
for (var i = node.content.length; i--;) {
26+
if (!node.content[i].is('delim')) continue;
2627

27-
if (node[i + 1][0] === 's') {
28-
node[i + 1][1] = value;
29-
} else if (node[i + 1][1][0] === 's') {
30-
node[i + 1][1][1] = value;
28+
if (node.content[i + 1].is('s')) {
29+
node.content[i + 1].content = value;
30+
} else if (node.content[i + 1].content[0].is('s')) {
31+
node.content[i + 1].content[0].content = value;
3132
} else {
32-
node[i + 1].splice(1, 0, ['s', value]);
33+
var space = gonzales.createNode({ type: 's', content: value });
34+
node.content[i + 1].content.unshift(space);
3335
}
3436
}
3537
},

test/options/space-after-selector-delimiter-sass/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe.skip('options/space-after-selector-delimiter (sass):', function() {
1+
describe('options/space-after-selector-delimiter (sass):', function() {
22
it('Issue 238', function() {
33
this.comb.configure({ 'space-after-selector-delimiter': '\n' });
44
this.shouldBeEqual('issue-238.sass', 'issue-238.expected.sass');

test/options/space-after-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-after-selector-delimiter:', function() {
1+
describe('options/space-after-selector-delimiter:', function() {
22
it('Array value => should not change anything', function() {
33
this.comb.configure({ 'space-after-selector-delimiter': ['', ' '] });
44
this.shouldBeEqual('test.css');
@@ -29,47 +29,47 @@ describe.skip('options/space-after-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-after-selector-delimiter'],
3535
'a,b{top:0}',
3636
{ 'space-after-selector-delimiter': '' }
3737
);
3838
});
3939

40-
it('Should detect whitespace', function() {
40+
it.skip('Should detect whitespace', function() {
4141
this.shouldDetect(
4242
['space-after-selector-delimiter'],
4343
'a, \n b {top:0}',
4444
{ 'space-after-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-after-selector-delimiter'],
5151
'a,b{top:0} a, b{left:0}',
5252
{ 'space-after-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-after-selector-delimiter'],
5959
'a, b {top:0} b,a{left:0}',
6060
{ 'space-after-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-after-selector-delimiter'],
6767
'a, b{top:0} b,c{left:0} c,d{right:0}',
6868
{ 'space-after-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-after-selector-delimiter'],
7575
'a,b{top:0} b, c{left:0} c, sd{right:0}',

0 commit comments

Comments
 (0)