...
 
Commits (10)
# html-validate changelog
## [1.14.1](https://gitlab.com/html-validate/html-validate/compare/v1.14.0...v1.14.1) (2019-10-27)
### Bug Fixes
- input hidden should not have label ([66cf13d](https://gitlab.com/html-validate/html-validate/commit/66cf13d489cbb641fabe83121fa0f135440875f8)), closes [#53](https://gitlab.com/html-validate/html-validate/issues/53)
# [1.14.0](https://gitlab.com/html-validate/html-validate/compare/v1.13.0...v1.14.0) (2019-10-20)
### Features
......
This diff is collapsed.
{
"name": "html-validate",
"version": "1.14.0",
"version": "1.14.1",
"description": "html linter",
"keywords": [
"html",
......@@ -116,22 +116,22 @@
"@babel/preset-env": "7.6.3",
"@commitlint/cli": "8.2.0",
"@commitlint/config-conventional": "8.2.0",
"@semantic-release/changelog": "3.0.4",
"@semantic-release/exec": "3.3.7",
"@semantic-release/git": "7.0.16",
"@semantic-release/gitlab": "4.0.0",
"@semantic-release/npm": "5.2.0",
"@semantic-release/release-notes-generator": "7.3.0",
"@semantic-release/changelog": "3.0.5",
"@semantic-release/exec": "3.3.8",
"@semantic-release/git": "7.0.17",
"@semantic-release/gitlab": "4.0.3",
"@semantic-release/npm": "5.3.1",
"@semantic-release/release-notes-generator": "7.3.2",
"@types/babel__code-frame": "7.0.1",
"@types/estree": "0.0.39",
"@types/glob": "7.1.1",
"@types/jest": "24.0.19",
"@types/json-merge-patch": "0.0.4",
"@types/minimist": "1.2.0",
"@types/node": "11.13.22",
"@typescript-eslint/eslint-plugin": "2.4.0",
"@typescript-eslint/parser": "2.4.0",
"autoprefixer": "9.6.5",
"@types/node": "11.15.0",
"@typescript-eslint/eslint-plugin": "2.5.0",
"@typescript-eslint/parser": "2.5.0",
"autoprefixer": "9.7.0",
"babelify": "10.0.0",
"bootstrap-sass": "3.4.1",
"canonical-path": "1.0.0",
......@@ -142,7 +142,7 @@
"eslint-config-sidvind": "1.3.2",
"eslint-plugin-array-func": "3.1.3",
"eslint-plugin-import": "2.18.2",
"eslint-plugin-jest": "22.19.0",
"eslint-plugin-jest": "22.20.0",
"eslint-plugin-node": "10.0.0",
"eslint-plugin-prettier": "3.1.1",
"eslint-plugin-security": "1.4.0",
......@@ -165,8 +165,8 @@
"load-grunt-tasks": "5.1.0",
"minimatch": "3.0.4",
"prettier": "1.18.2",
"sass": "1.23.0",
"semantic-release": "15.13.27",
"sass": "1.23.1",
"semantic-release": "15.13.28",
"serve-static": "1.14.1",
"strip-ansi": "5.2.0",
"ts-jest": "24.1.0",
......
......@@ -17,6 +17,11 @@ describe("rule input-missing-label", () => {
expect(report).toBeValid();
});
it('should not report input type="hidden" is missing label', () => {
const report = htmlvalidate.validateString('<input type="hidden" />');
expect(report).toBeValid();
});
it("should not report when input is nested inside label", () => {
const report = htmlvalidate.validateString("<label>foo <input/></label>");
expect(report).toBeValid();
......
......@@ -15,6 +15,14 @@ class InputMissingLabel extends Rule {
this.on("dom:ready", (event: DOMReadyEvent) => {
const root = event.document;
for (const elem of root.querySelectorAll("input, textarea, select")) {
/* <input type="hidden"> should not have label */
if (elem.is("input")) {
const type = elem.getAttributeValue("type");
if (type && type.toLowerCase() === "hidden") {
continue;
}
}
/* try to find label by id */
if (findLabelById(root, elem.id)) {
continue;
......