Skip to content

Commit a1d900a

Browse files
henriklundgrennecolas
authored andcommitted
Allow empty property values
1 parent b5b5e38 commit a1d900a

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,11 @@ module.exports = function(css, options){
219219

220220
// val
221221
var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/);
222-
if (!val) return error('property missing value');
223222

224223
var ret = pos({
225224
type: 'declaration',
226225
property: prop.replace(commentre, ''),
227-
value: trim(val[0]).replace(commentre, '')
226+
value: val ? trim(val[0]).replace(commentre, '') : ''
228227
});
229228

230229
// ;

test/css-parse.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('parse(str)', function(){
2020
var ret = parse(css, { source: file + '.css' });
2121
ret = JSON.stringify(ret, null, 2);
2222
ret.should.equal(json);
23-
})
23+
});
2424
});
2525

2626
it('should save the filename and source', function(){
@@ -29,7 +29,7 @@ describe('parse(str)', function(){
2929
source: 'booty.css'
3030
});
3131

32-
var position = ast.stylesheet.rules[0].position
32+
var position = ast.stylesheet.rules[0].position;
3333
position.start.should.be.ok;
3434
position.end.should.be.ok;
3535
position.source.should.equal('booty.css');
@@ -44,7 +44,7 @@ describe('parse(str)', function(){
4444
assert.throws(function(){
4545
parse('b { color: red; }\n{ color: green; }\na {color: blue; }');
4646
});
47-
})
47+
});
4848

4949
it('should throw when a broken comment is found', function () {
5050
assert.throws(function(){
@@ -59,5 +59,11 @@ describe('parse(str)', function(){
5959
assert.doesNotThrow(function(){
6060
parse('/* /* */');
6161
});
62-
})
63-
})
62+
});
63+
64+
it('should allow empty property value', function() {
65+
assert.doesNotThrow(function() {
66+
parse('p { color:; }');
67+
});
68+
});
69+
});

0 commit comments

Comments
 (0)