Skip to content

chore: clean up a11y analysis code #16345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jul 14, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
apply changes from #16340 and #16341
  • Loading branch information
Ocean-OS committed Jul 11, 2025
commit 7df34a355429c94f84ff93ce96d4b73d700878ae
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ import { roles as roles_map, aria } from 'aria-query';
import { AXObjectRoles, elementAXObjects } from 'axobject-query';
import {
regex_heading_tags,
regex_js_prefix,
regex_not_whitespace,
regex_redundant_img_alt,
regex_starts_with_vowel,
regex_whitespaces
} from '../../../../patterns.js';
Expand Down Expand Up @@ -533,7 +535,9 @@ export function check_element(node, context) {
}
// no-autofocus
case 'autofocus': {
w.a11y_autofocus(attribute);
if (node.name !== 'dialog' && !is_parent(context.path, ['dialog'])) {
w.a11y_autofocus(attribute);
}
break;
}
// scope
Expand Down Expand Up @@ -673,7 +677,7 @@ export function check_element(node, context) {
if (href) {
const href_value = get_static_text_value(href);
if (href_value !== null) {
if (href_value === '' || href_value === '#' || /^\W*javascript:/i.test(href_value)) {
if (href_value === '' || href_value === '#' || regex_js_prefix.test(href_value)) {
w.a11y_invalid_attribute(href, href_value, href.name);
}
}
Expand Down Expand Up @@ -715,7 +719,7 @@ export function check_element(node, context) {
const alt_attribute = get_static_text_value(attribute_map.get('alt'));
const aria_hidden = get_static_value(attribute_map.get('aria-hidden'));
if (alt_attribute && !aria_hidden && !has_spread) {
if (/\b(image|picture|photo)\b/i.test(alt_attribute)) {
if (regex_redundant_img_alt.test(alt_attribute)) {
w.a11y_img_redundant_alt(node);
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/svelte/src/compiler/phases/patterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ export const regex_heading_tags = /^h[1-6]$/;
export const regex_illegal_attribute_character = /(^[0-9-.])|[\^$@%&#?!|()[\]{}^*+~;]/;
export const regex_bidirectional_control_characters =
/[\u202a\u202b\u202c\u202d\u202e\u2066\u2067\u2068\u2069]+/g;
export const regex_js_prefix = /^\W*javascript:/i;
export const regex_redundant_img_alt = /\b(image|picture|photo)\b/i;
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy