From 10f7b5ee70f122177887347dde0ac6934eb8bba4 Mon Sep 17 00:00:00 2001 From: Bassam Ismail Date: Wed, 24 Jun 2020 01:36:05 +0530 Subject: [PATCH] skip a11y-missing-content check with contenteditable bindings (#5023) --- src/compiler/compile/nodes/Element.ts | 4 ++++ .../errors.json | 17 +++++++++++++++++ .../input.svelte | 6 ++++++ 3 files changed, 27 insertions(+) create mode 100644 test/validator/samples/a11y-contenteditable-element-without-child/errors.json create mode 100644 test/validator/samples/a11y-contenteditable-element-without-child/input.svelte diff --git a/src/compiler/compile/nodes/Element.ts b/src/compiler/compile/nodes/Element.ts index 517ed3ceb6..7a70e603a7 100644 --- a/src/compiler/compile/nodes/Element.ts +++ b/src/compiler/compile/nodes/Element.ts @@ -706,6 +706,10 @@ export default class Element extends Node { validate_content() { if (!a11y_required_content.has(this.name)) return; + if ( + this.bindings + .some((binding) => ['textContent', 'innerHTML'].includes(binding.name)) + ) return; if (this.children.length === 0) { this.component.warn(this, { diff --git a/test/validator/samples/a11y-contenteditable-element-without-child/errors.json b/test/validator/samples/a11y-contenteditable-element-without-child/errors.json new file mode 100644 index 0000000000..dd2a915b9d --- /dev/null +++ b/test/validator/samples/a11y-contenteditable-element-without-child/errors.json @@ -0,0 +1,17 @@ +[ + { + "code": "missing-contenteditable-attribute", + "message": "'contenteditable' attribute is required for textContent and innerHTML two-way bindings", + "start": { + "line": 6, + "column": 3, + "character": 157 + }, + "end": { + "line": 6, + "column": 24, + "character": 178 + }, + "pos": 157 + } +] diff --git a/test/validator/samples/a11y-contenteditable-element-without-child/input.svelte b/test/validator/samples/a11y-contenteditable-element-without-child/input.svelte new file mode 100644 index 0000000000..0702c3cb45 --- /dev/null +++ b/test/validator/samples/a11y-contenteditable-element-without-child/input.svelte @@ -0,0 +1,6 @@ + +

+

+