Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/rules/attr-no-unnecessary-whitespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ export default {
var col = event.col + event.tagName.length + 1

for (var i = 0; i < attrs.length; i++) {
if (
exceptions.indexOf(attrs[i].name) === -1 &&
/[^=](\s+=\s+|=\s+|\s+=)/g.test(attrs[i].raw.trim())
) {
reporter.error(
"The attribute '" +
attrs[i].name +
"' must not have spaces between the name and value.",
event.line,
col + attrs[i].index,
self,
attrs[i].raw
)
if (exceptions.indexOf(attrs[i].name) === -1) {
var match = /(\s*)=(\s*)/.exec(attrs[i].raw.trim())
if (match && (match[1].length !== 0 || match[2].length !== 0)) {
reporter.error(
"The attribute '" +
attrs[i].name +
"' must not have spaces between the name and value.",
event.line,
col + attrs[i].index,
self,
attrs[i].raw
)
}
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ describe('Rules: ' + ruldId, function () {
})

it('Attribute without spaces should not result in an error', function () {
var code = '<div title="a" />'
var messages = HTMLHint.verify(code, ruleOptions)
expect(messages.length).to.be(0)
var codes = ['<div title="a" />', '<div title="a = a" />']
for (var i = 0; i < codes.length; i++) {
var messages = HTMLHint.verify(codes[i], ruleOptions)
expect(messages.length).to.be(0)
}
})
})