Skip to content

Commit

Permalink
fix attr-value-double-quotes: without quotes should not result in an …
Browse files Browse the repository at this point in the history
…error
  • Loading branch information
yaniswang committed Sep 1, 2013
1 parent 98a54ea commit 533e176
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
HTMLHint change log
====================

## ver 0.9.4 (2013-9-1)

fix:

1. fix attr-value-double-quotes: without quotes should not result in an error

## ver 0.9.3 (2013-5-24)

add:
Expand Down
2 changes: 1 addition & 1 deletion bin/htmlhint
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ program.on('--help', function(){
});

program
.version('0.9.3')
.version('0.9.4')
.usage('[options] <file ...>')
.option('-l, --list', 'show all of the rules available.')
.option('-c, --config <file>', 'custom configuration file.')
Expand Down
2 changes: 1 addition & 1 deletion coverage.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lib/htmlhint.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "htmlhint",
"version": "0.9.3",
"version": "0.9.4",
"description": "A Static Code Analysis Tool for HTML",
"main": "./index",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/attr-value-double-quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ HTMLHint.addRule({
col = event.col + event.tagName.length + 1;
for(var i=0, l=attrs.length;i<l;i++){
attr = attrs[i];
if(attr.quote !== '"' && (attr.value !== '' || (attr.value === attr.quote === ''))){
if(attr.quote !== '"' && attr.quote !== ''){
reporter.error('The value of attribute [ '+attr.name+' ] must closed by double quotes.', event.line, col + attr.index, self, attr.raw);
}
}
Expand Down
13 changes: 8 additions & 5 deletions test/rules/attr-value-double-quotes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@ var HTMLHint = require("../../index").HTMLHint;
describe('Rules: attr-value-double-quotes', function(){

it('Attribute value closed by single quotes should result in an error', function(){
var code = '<a href=\'abc\' title=abc>';
var code = '<a href=\'abc\'>';
var messages = HTMLHint.verify(code, {'attr-value-double-quotes': true});
expect(messages.length).to.be(2);
expect(messages.length).to.be(1);
expect(messages[0].rule.id).to.be('attr-value-double-quotes');
expect(messages[0].line).to.be(1);
expect(messages[0].col).to.be(3);
expect(messages[1].rule.id).to.be('attr-value-double-quotes');
expect(messages[1].line).to.be(1);
expect(messages[1].col).to.be(14);
});

it('Attribute value no closed should not result in an error', function(){
Expand All @@ -33,4 +30,10 @@ describe('Rules: attr-value-double-quotes', function(){
expect(messages.length).to.be(0);
});

it('Attribute value without quotes should not result in an error', function(){
var code = '<input type=text>';
var messages = HTMLHint.verify(code, {'attr-value-double-quotes': false});
expect(messages.length).to.be(0);
});

});

0 comments on commit 533e176

Please sign in to comment.