Skip to content

Commit cd53062

Browse files
committed
Update Gonzales to v2.0.1
- `propertyDelim` node was added (that is `:` between properties and values) - `decldelim` node was renamed to `declDelim` - `funktion` node was renamed to `function`
1 parent 2059d61 commit cd53062

4 files changed

Lines changed: 25 additions & 15 deletions

File tree

lib/options/always-semicolon.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,25 @@ module.exports = {
2222
for (var i = node.length; i--;) {
2323
var nodeItem = node[i];
2424
var type = nodeItem[0];
25-
var value = nodeItem[2];
2625

27-
if (type === 'decldelim') break;
26+
if (type === 'declDelim') break;
2827

2928
if (type === 'declaration') {
29+
// Look for value node:
30+
var value;
31+
for (var k = nodeItem.length; k--;) {
32+
if (nodeItem[k][0] === 'value') {
33+
value = nodeItem[k];
34+
break;
35+
}
36+
}
37+
3038
var space = [];
3139
for (var j = value.length; j--;) {
3240
if (['s', 'commentML', 'commentSL'].indexOf(value[j][0]) === -1) break;
3341
space.unshift(value.splice(j)[0]);
3442
}
35-
node.splice.apply(node, [i + 1, 0, ['decldelim']].concat(space));
43+
node.splice.apply(node, [i + 1, 0, ['declDelim']].concat(space));
3644
break;
3745
}
3846
}

lib/options/sort-order.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ module.exports = {
164164

165165
// If there is `;` right after the declaration, save it with the
166166
// declaration and mark it for removing from parent node:
167-
if (currentNode && nextNode && nextNode[0] === 'decldelim') {
167+
if (currentNode && nextNode && nextNode[0] === 'declDelim') {
168168
extendedNode.delim.push(nextNode);
169169
deleted.push(i + 1);
170170
i++;
@@ -224,7 +224,7 @@ module.exports = {
224224
}
225225

226226
if (!propertyName) {
227-
deleted = [];
227+
deleted.splice(deleted.length - sc0.length, deleted.length + 1);
228228
continue;
229229
}
230230

@@ -274,7 +274,7 @@ module.exports = {
274274
for (j = 0, nl = sc1.length; j < nl; j++) {
275275
node.unshift(sc1[j]);
276276
}
277-
if (currentNode.delim.length > 0) node.unshift(['decldelim']);
277+
if (currentNode.delim.length > 0) node.unshift(['declDelim']);
278278
node.unshift(currentNode.node);
279279
for (j = 0, nl = sc0.length; j < nl; j++) {
280280
node.unshift(sc0[j]);

lib/options/vendor-prefix-align.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ module.exports = {
2525
var result = { baseName: propertyName, prefixLength: 0 };
2626

2727
this._prefixesList.some(function(prefix) {
28+
// TODO: Why don't we store prefixes with `-`?
2829
prefix = '-' + prefix + '-';
2930
if (propertyName.indexOf(prefix) !== 0) return;
3031
result = {
@@ -65,6 +66,7 @@ module.exports = {
6566
*/
6667
_getDeclName: function(node) {
6768
if (node[0] !== 'declaration') return;
69+
// TODO: Check that it's not a variable
6870
return node[1][1][1];
6971
},
7072

@@ -81,12 +83,13 @@ module.exports = {
8183
* @returns {String|undefined}
8284
*/
8385
_getValName: function(node) {
84-
if (node[0] !== 'declaration' || !node[2] || !node[2][2])
86+
// TODO: Check that `node[3]` is the node we need
87+
if (node[0] !== 'declaration' || !node[3] || !node[3])
8588
return;
86-
if (node[2][2][0] === 'ident')
87-
return node[2][2][1];
88-
if (node[2][2][0] === 'funktion')
89-
return node[2][2][1][1];
89+
if (node[3][2][0] === 'ident')
90+
return node[3][2][1];
91+
if (node[3][2][0] === 'function')
92+
return node[3][2][1][1];
9093
},
9194

9295
/**
@@ -156,16 +159,15 @@ module.exports = {
156159
_this._updateDict(info, dict, node[i - 1][1]);
157160
});
158161
this._walk(node, this._getValName, function(info, i) {
159-
_this._updateDict(info, dict, node[i][2][1][1]);
162+
_this._updateDict(info, dict, node[i][3][1][1]);
160163
});
161164

162165
// Update nodes
163166
this._walk(node, this._getDeclName, function(info, i) {
164167
node[i - 1][1] = _this._updateIndent(info, dict, node[i - 1][1]);
165168
});
166169
this._walk(node, this._getValName, function(info, i) {
167-
node[i][2][1][1] = _this._updateIndent(info, dict, node[i][2][1][1]);
170+
node[i][3][1][1] = _this._updateIndent(info, dict, node[i][3][1][1]);
168171
});
169172
}
170-
171173
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
},
4141
"dependencies": {
4242
"commander": "2.0.0",
43-
"gonzales-pe": "2.0.0-rc0",
43+
"gonzales-pe": "2.0.1",
4444
"minimatch": "0.2.12",
4545
"vow": "0.3.11",
4646
"vow-fs": "0.2.3"

0 commit comments

Comments
 (0)