Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions lib/options/always-semicolon.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,25 @@ module.exports = {
for (var i = node.length; i--;) {
var nodeItem = node[i];
var type = nodeItem[0];
var value = nodeItem[2];

if (type === 'decldelim') break;
if (type === 'declDelim') break;

if (type === 'declaration') {
// Look for value node:
var value;
for (var k = nodeItem.length; k--;) {
if (nodeItem[k][0] === 'value') {
value = nodeItem[k];
break;
}
}

var space = [];
for (var j = value.length; j--;) {
if (['s', 'commentML', 'commentSL'].indexOf(value[j][0]) === -1) break;
space.unshift(value.splice(j)[0]);
}
node.splice.apply(node, [i + 1, 0, ['decldelim']].concat(space));
node.splice.apply(node, [i + 1, 0, ['declDelim']].concat(space));
break;
}
}
Expand Down
6 changes: 3 additions & 3 deletions lib/options/sort-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ module.exports = {

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

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

Expand Down Expand Up @@ -274,7 +274,7 @@ module.exports = {
for (j = 0, nl = sc1.length; j < nl; j++) {
node.unshift(sc1[j]);
}
if (currentNode.delim.length > 0) node.unshift(['decldelim']);
if (currentNode.delim.length > 0) node.unshift(['declDelim']);
node.unshift(currentNode.node);
for (j = 0, nl = sc0.length; j < nl; j++) {
node.unshift(sc0[j]);
Expand Down
18 changes: 10 additions & 8 deletions lib/options/vendor-prefix-align.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module.exports = {
var result = { baseName: propertyName, prefixLength: 0 };

this._prefixesList.some(function(prefix) {
// TODO: Why don't we store prefixes with `-`?
prefix = '-' + prefix + '-';
if (propertyName.indexOf(prefix) !== 0) return;
result = {
Expand Down Expand Up @@ -65,6 +66,7 @@ module.exports = {
*/
_getDeclName: function(node) {
if (node[0] !== 'declaration') return;
// TODO: Check that it's not a variable
return node[1][1][1];
},

Expand All @@ -81,12 +83,13 @@ module.exports = {
* @returns {String|undefined}
*/
_getValName: function(node) {
if (node[0] !== 'declaration' || !node[2] || !node[2][2])
// TODO: Check that `node[3]` is the node we need
if (node[0] !== 'declaration' || !node[3] || !node[3])
return;
if (node[2][2][0] === 'ident')
return node[2][2][1];
if (node[2][2][0] === 'funktion')
return node[2][2][1][1];
if (node[3][2][0] === 'ident')
return node[3][2][1];
if (node[3][2][0] === 'function')
return node[3][2][1][1];
},

/**
Expand Down Expand Up @@ -156,16 +159,15 @@ module.exports = {
_this._updateDict(info, dict, node[i - 1][1]);
});
this._walk(node, this._getValName, function(info, i) {
_this._updateDict(info, dict, node[i][2][1][1]);
_this._updateDict(info, dict, node[i][3][1][1]);
});

// Update nodes
this._walk(node, this._getDeclName, function(info, i) {
node[i - 1][1] = _this._updateIndent(info, dict, node[i - 1][1]);
});
this._walk(node, this._getValName, function(info, i) {
node[i][2][1][1] = _this._updateIndent(info, dict, node[i][2][1][1]);
node[i][3][1][1] = _this._updateIndent(info, dict, node[i][3][1][1]);
});
}

};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"dependencies": {
"commander": "2.0.0",
"gonzales-pe": "2.0.0-rc0",
"gonzales-pe": "2.0.1",
"minimatch": "0.2.12",
"vow": "0.3.11",
"vow-fs": "0.2.3"
Expand Down