Problem with form action attribute-allowed-values (and tests)
attribute-allowed-values rule rejects valid values for
<form action="..."> attribute. I think the fix should be simple (see below) but there is an added problem of current tests passing that shouldn't be passing.
To reproduce, edit file
html-validate/test-files/elements/form-valid.html and duplicate line 18 so you end up with:
... <!-- should allow action attribute --> <form action="/target"></form> <form action="/target"></form> ...
npm test -- -i elements/html5.spec.ts will fail (on the original line 18).
A fresh git clone / npm test of html-validate.
Test to pass because
"/target" is a valid value.
Test fails with error
Attribute "action" has invalid value "/target".
Suggested fix (to primary issue)
I didn't dig into why the test originally passes when it shouldn't, but for the actual problem with the rule I played around a little. From looking (quickly) at
Validator.validateAttributeValue and the rules, I'm guessing the problem is that the rule definition (in
elements/html5.js line 534) is currently specifying the regular expression as a string instead of a RegExp. Changing the regular expression value from
/\s*\S+\s*/ seems to fix the issue, but with side-effects of making tests from
html-validate/test-files/elements/form-invalid.html fail (that should pass).