diff --git a/src/compiler/compile/nodes/Element.ts b/src/compiler/compile/nodes/Element.ts index 5cc44ce15f87..d4a3b85e6c25 100644 --- a/src/compiler/compile/nodes/Element.ts +++ b/src/compiler/compile/nodes/Element.ts @@ -25,7 +25,7 @@ import { Literal } from 'estree'; import compiler_warnings from '../compiler_warnings'; import compiler_errors from '../compiler_errors'; import { ARIARoleDefinitionKey, roles, aria, ARIAPropertyDefinition, ARIAProperty } from 'aria-query'; -import { is_non_interactive_element, is_interactive_element, is_non_interactive_roles, is_presentation_role, is_interactive_roles, is_hidden_from_screen_reader, is_semantic_role_element, is_abstract_role, is_static_element, has_disabled_attribute, is_interactive_handler } from '../utils/a11y'; +import { is_non_interactive_element, is_interactive_element, is_non_interactive_roles, is_presentation_role, is_interactive_roles, is_hidden_from_screen_reader, is_semantic_role_element, is_abstract_role, is_static_element, has_disabled_attribute } from '../utils/a11y'; const aria_attributes = 'activedescendant atomic autocomplete busy checked colcount colindex colspan controls current describedby description details disabled dropeffect errormessage expanded flowto grabbed haspopup hidden invalid keyshortcuts label labelledby level live modal multiline multiselectable orientation owns placeholder posinset pressed readonly relevant required roledescription rowcount rowindex rowspan selected setsize sort valuemax valuemin valuenow valuetext'.split(' '); const aria_attribute_set = new Set(aria_attributes); @@ -777,7 +777,9 @@ export default class Element extends Node { !is_non_interactive_roles(role) && !is_abstract_role(role) ) { - const interactive_handlers = handlers.map((handler) => handler.name).filter(is_interactive_handler); + const interactive_handlers = handlers + .map((handler) => handler.name) + .filter((handlerName) => a11y_interactive_handlers.has(handlerName)); if (interactive_handlers.length > 0) { component.warn( this, diff --git a/src/compiler/compile/utils/a11y.ts b/src/compiler/compile/utils/a11y.ts index fbc4327468a9..0936988072b1 100644 --- a/src/compiler/compile/utils/a11y.ts +++ b/src/compiler/compile/utils/a11y.ts @@ -241,41 +241,3 @@ export function is_semantic_role_element( } return false; } - -const interactive_handlers = new Set([ - // Focus - 'focus', - 'focusin', - 'focusout', - 'blur', - - // Keyboard - 'keydown', - 'keypress', - 'keyup', - - // Mouse - 'auxclick', - 'click', - 'contextmenu', - 'dblclick', - 'drag', - 'dragend', - 'dragenter', - 'dragexit', - 'dragleave', - 'dragover', - 'dragstart', - 'drop', - 'mousedown', - 'mouseenter', - 'mouseleave', - 'mousemove', - 'mouseout', - 'mouseover', - 'mouseup' -]); - -export function is_interactive_handler(handler: string) { - return interactive_handlers.has(handler); -} diff --git a/test/validator/samples/a11y-no-static-element-interactions/input.svelte b/test/validator/samples/a11y-no-static-element-interactions/input.svelte index 96b5c369cc01..b5281645fba0 100644 --- a/test/validator/samples/a11y-no-static-element-interactions/input.svelte +++ b/test/validator/samples/a11y-no-static-element-interactions/input.svelte @@ -9,6 +9,8 @@