From 84d20850d144cdbfb2c4f369fb9cbc85f711e6ff Mon Sep 17 00:00:00 2001 From: Laurent Goderre Date: Tue, 3 Dec 2013 09:32:23 -0500 Subject: [PATCH] Don't output CSS unit for value 0 --- tasks/sprites.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/sprites.js b/tasks/sprites.js index c8462dc..95a35be 100644 --- a/tasks/sprites.js +++ b/tasks/sprites.js @@ -67,7 +67,7 @@ module.exports = function(grunt) { fileContents += imageClasses + ' {' + '\n' + ' background: url("' + generateBackgroundImagePath() + '") no-repeat;\n' + '}\n\n'; imageData.heights.forEach(function (height, idx) { - fileContents += '.' + (classPrefix === '' ? '' : classPrefix + '-') + path.basename(images[idx].file, '.png') + ' {\n' + ' background-position: 0 ' + -height + 'px;\n' + '}\n\n'; + fileContents += '.' + (classPrefix === '' ? '' : classPrefix + '-') + path.basename(images[idx].file, '.png') + ' {\n' + ' background-position: 0 ' + -height + ( height === 0 ? "" : 'px') + ';\n' + '}\n\n'; }); return fileContents; @@ -78,7 +78,7 @@ module.exports = function(grunt) { fileContents += "%" + placeholder + (scssSyntax ? ' {' : '') + '\n' + ' background: url("' + generateBackgroundImagePath() + '") no-repeat' + (scssSyntax ? ';\n }' : '') + '\n\n'; imageData.heights.forEach(function (height, idx) { - fileContents += '%' + (classPrefix === '' ? '' : classPrefix + '-') + path.basename(images[idx].file, '.png') + (scssSyntax ? ' {' : '') + '\n @extend ' + '%' + placeholder + (scssSyntax ? ' ;' : '') + '\n' + ' background-position: 0 ' + -height + 'px' + (scssSyntax ? ';\n }' : '') + '\n\n'; + fileContents += '%' + (classPrefix === '' ? '' : classPrefix + '-') + path.basename(images[idx].file, '.png') + (scssSyntax ? ' {' : '') + '\n @extend ' + '%' + placeholder + (scssSyntax ? ' ;' : '') + '\n' + ' background-position: 0 ' + -height + ( height === 0 ? "" : 'px') + (scssSyntax ? ';\n }' : '') + '\n\n'; }); return fileContents; @@ -90,7 +90,7 @@ module.exports = function(grunt) { fileContents += "." + placeholder + ' {\n' + ' background: url("' + generateBackgroundImagePath() + '") no-repeat;\n }' + '\n\n'; imageData.heights.forEach(function (height, idx) { - fileContents += '.' + (classPrefix === '' ? '' : classPrefix + '-') + path.basename(images[idx].file, '.png') + ':extend(.' + placeholder + ') {\n' + ' background-position: 0 ' + -height + 'px;\n' + '}\n\n'; + fileContents += '.' + (classPrefix === '' ? '' : classPrefix + '-') + path.basename(images[idx].file, '.png') + ':extend(.' + placeholder + ') {\n' + ' background-position: 0 ' + -height + ( height === 0 ? "" : 'px') + ';\n' + '}\n\n'; }); return fileContents;