From 9c2b60a58679f9f80e8f5136ff7bd0f3d1da668e Mon Sep 17 00:00:00 2001 From: Mikhail Troshev Date: Thu, 8 Aug 2013 08:33:04 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B8=D1=88=D0=BD=D0=B8=D0=B5=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D0=BD=D0=BE=D1=81=D1=8B=20=D1=81=D1=82=D1=80?= =?UTF-8?q?=D0=BE=D0=BA=20"stick-brace":=20"\n"=20(close=20#19)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/options/colon-space.js | 1 + lib/options/stick-brace.js | 13 ++++++++++--- test/stick-brace.js | 4 ++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/options/colon-space.js b/lib/options/colon-space.js index e0125134..881ab373 100644 --- a/lib/options/colon-space.js +++ b/lib/options/colon-space.js @@ -7,6 +7,7 @@ module.exports = { * @returns {Object} */ setValue: function(value) { + this._value = false; if (value === true) this._value = 'after'; if (typeof value === 'string' && value.match(/after|before|both/)) this._value = value; if (!this._value) return; diff --git a/lib/options/stick-brace.js b/lib/options/stick-brace.js index 264f2acf..0ec3b27e 100644 --- a/lib/options/stick-brace.js +++ b/lib/options/stick-brace.js @@ -7,6 +7,7 @@ module.exports = { * @returns {Object} */ setValue: function(value) { + this._value = false; if (value === true) value = ' '; if (typeof value === 'string' && value.match(/^[ \t\n]*$/)) this._value = value; if (!this._value) return; @@ -19,9 +20,15 @@ module.exports = { * @param {node} node */ process: function(nodeType, node) { - if (nodeType === 'simpleselector') { - if (node[node.length - 1][0] === 's') node.pop(); - node.push(['s', this._value]); + if (nodeType === 'selector') { + for (var i = node.length; i--;) { + var nodeItem = node[i]; + if (nodeItem[0] === 'simpleselector') { + if (nodeItem[nodeItem.length - 1][0] === 's') nodeItem.pop(); + nodeItem.push(['s', this._value]); + break; + } + } } } diff --git a/test/stick-brace.js b/test/stick-brace.js index 3cdfb7fa..d8e66cc0 100644 --- a/test/stick-brace.js +++ b/test/stick-brace.js @@ -18,11 +18,13 @@ describe('options/stick-brace', function() { assert.equal( comb.processString( 'a { color: red }' + + 'a,\nb /* i */\n{ color: red }' + 'a{color:red}' + 'a \t\t \n{color:red}' + 'a /* foo */ {color:red}' ), 'a { color: red }' + + 'a,\nb /* i */ { color: red }' + 'a {color:red}' + 'a {color:red}' + 'a /* foo */ {color:red}' @@ -33,11 +35,13 @@ describe('options/stick-brace', function() { assert.equal( comb.processString( 'a { color: red }' + + 'a, b /* i */ { color: red }' + 'a{color:red}' + 'a \t\t \n{color:red}' + 'a /* foo */ {color:red}' ), 'a\n{ color: red }' + + 'a, b /* i */\n{ color: red }' + 'a\n{color:red}' + 'a\n{color:red}' + 'a /* foo */\n{color:red}'