From: Kyle Robinson Young Date: Wed, 23 Oct 2013 21:08:11 +0000 (-0700) Subject: Allow keepSpecialComments to be set as a string X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=f23c8260ea9fa0923badac40879cce6b2f570af2;p=clean-css.git Allow keepSpecialComments to be set as a string --- diff --git a/lib/text/comments.js b/lib/text/comments.js index a1b6e439..7528b752 100644 --- a/lib/text/comments.js +++ b/lib/text/comments.js @@ -45,10 +45,12 @@ module.exports = function Comments(keepSpecialComments, keepBreaks, lineBreak) { case '*': return comments.restore(placeholder) + breakSuffix; case 1: + case '1': return restored == 1 ? comments.restore(placeholder) + breakSuffix : ''; case 0: + case '0': return ''; } }); diff --git a/test/unit-test.js b/test/unit-test.js index 32d72916..64c8743c 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -273,6 +273,12 @@ vows.describe('clean-units').addBatch({ "@charset 'utf-8';a{}" ] }, { keepSpecialComments: 0 }), + 'important comments - keepSpecialComments when a string': cssContext({ + 'strip all': [ + '/*! important comment */a{color:red}/* some comment *//*! important comment */', + 'a{color:red}' + ] + }, { keepSpecialComments: '0' }), 'expressions': cssContext({ 'empty': 'a{color:expression()}', 'method call': 'a{color:expression(this.parentNode.currentStyle.color)}',