diff --git a/app/lib/frontend/templates/detail_page.dart b/app/lib/frontend/templates/detail_page.dart index d00e3f922b..69108a7dac 100644 --- a/app/lib/frontend/templates/detail_page.dart +++ b/app/lib/frontend/templates/detail_page.dart @@ -95,8 +95,13 @@ class Tab { if (isPrivate) '-private', ]; - d.Node get titleNode => - href == null ? d.text(title) : d.a(href: href, text: title); + d.Node get titleNode => href == null + ? d.text(title) + : d.a( + href: href, + text: title, + attributes: {'role': 'button'}, + ); bool get hasContent => contentNode != null; diff --git a/app/lib/frontend/templates/views/shared/detail/tabs.dart b/app/lib/frontend/templates/views/shared/detail/tabs.dart index c834c58bfb..bbba670f07 100644 --- a/app/lib/frontend/templates/views/shared/detail/tabs.dart +++ b/app/lib/frontend/templates/views/shared/detail/tabs.dart @@ -19,7 +19,6 @@ d.Node detailTabsNode({ children: tabs.map( (t) => d.li( classes: t.titleClasses, - attributes: {'role': 'button'}, child: t.titleNode, ), ), diff --git a/app/test/frontend/golden/my_activity_log_page.html b/app/test/frontend/golden/my_activity_log_page.html index 6415e8f4bf..88357ad922 100644 --- a/app/test/frontend/golden/my_activity_log_page.html +++ b/app/test/frontend/golden/my_activity_log_page.html @@ -157,16 +157,16 @@

admin

diff --git a/app/test/frontend/golden/my_liked_packages.html b/app/test/frontend/golden/my_liked_packages.html index a7f995b8d7..0fd3f7a864 100644 --- a/app/test/frontend/golden/my_liked_packages.html +++ b/app/test/frontend/golden/my_liked_packages.html @@ -158,15 +158,15 @@

user

diff --git a/app/test/frontend/golden/my_packages.html b/app/test/frontend/golden/my_packages.html index e702b5ea37..ea2524eccc 100644 --- a/app/test/frontend/golden/my_packages.html +++ b/app/test/frontend/golden/my_packages.html @@ -157,15 +157,15 @@

user

diff --git a/app/test/frontend/golden/my_publishers.html b/app/test/frontend/golden/my_publishers.html index f88f0b50d1..7fc76f32e4 100644 --- a/app/test/frontend/golden/my_publishers.html +++ b/app/test/frontend/golden/my_publishers.html @@ -157,15 +157,15 @@

user

diff --git a/app/test/frontend/golden/pkg_activity_log_page.html b/app/test/frontend/golden/pkg_activity_log_page.html index c2a09cb0e1..5525b34209 100644 --- a/app/test/frontend/golden/pkg_activity_log_page.html +++ b/app/test/frontend/golden/pkg_activity_log_page.html @@ -212,28 +212,28 @@

Metadata

diff --git a/app/test/frontend/golden/pkg_admin_page.html b/app/test/frontend/golden/pkg_admin_page.html index e56476a5e8..3af3576be0 100644 --- a/app/test/frontend/golden/pkg_admin_page.html +++ b/app/test/frontend/golden/pkg_admin_page.html @@ -212,27 +212,27 @@

Metadata

diff --git a/app/test/frontend/golden/pkg_changelog_page.html b/app/test/frontend/golden/pkg_changelog_page.html index 82e2b28890..bdb6993140 100644 --- a/app/test/frontend/golden/pkg_changelog_page.html +++ b/app/test/frontend/golden/pkg_changelog_page.html @@ -186,21 +186,21 @@

Metadata

diff --git a/app/test/frontend/golden/pkg_example_page.html b/app/test/frontend/golden/pkg_example_page.html index ab2e23ed58..dc9e551571 100644 --- a/app/test/frontend/golden/pkg_example_page.html +++ b/app/test/frontend/golden/pkg_example_page.html @@ -186,21 +186,21 @@

Metadata

diff --git a/app/test/frontend/golden/pkg_install_page.html b/app/test/frontend/golden/pkg_install_page.html index f538cfaa3a..eb4ed95ac8 100644 --- a/app/test/frontend/golden/pkg_install_page.html +++ b/app/test/frontend/golden/pkg_install_page.html @@ -186,21 +186,21 @@

Metadata

diff --git a/app/test/frontend/golden/pkg_score_page.html b/app/test/frontend/golden/pkg_score_page.html index bf0f0920e8..9de666423d 100644 --- a/app/test/frontend/golden/pkg_score_page.html +++ b/app/test/frontend/golden/pkg_score_page.html @@ -186,22 +186,22 @@

Metadata

diff --git a/app/test/frontend/golden/pkg_show_page.html b/app/test/frontend/golden/pkg_show_page.html index 6958f33064..24e0043485 100644 --- a/app/test/frontend/golden/pkg_show_page.html +++ b/app/test/frontend/golden/pkg_show_page.html @@ -186,27 +186,27 @@

Metadata

diff --git a/app/test/frontend/golden/pkg_show_page_discontinued.html b/app/test/frontend/golden/pkg_show_page_discontinued.html index a9564f9c8a..0e83e5d648 100644 --- a/app/test/frontend/golden/pkg_show_page_discontinued.html +++ b/app/test/frontend/golden/pkg_show_page_discontinued.html @@ -172,21 +172,21 @@

Metadata

diff --git a/app/test/frontend/golden/pkg_show_page_flutter_plugin.html b/app/test/frontend/golden/pkg_show_page_flutter_plugin.html index 3b4f9b6e6a..0723eaebc7 100644 --- a/app/test/frontend/golden/pkg_show_page_flutter_plugin.html +++ b/app/test/frontend/golden/pkg_show_page_flutter_plugin.html @@ -175,27 +175,27 @@

Metadata

diff --git a/app/test/frontend/golden/pkg_show_page_publisher.html b/app/test/frontend/golden/pkg_show_page_publisher.html index e78eb28d64..9c8323fbce 100644 --- a/app/test/frontend/golden/pkg_show_page_publisher.html +++ b/app/test/frontend/golden/pkg_show_page_publisher.html @@ -180,21 +180,21 @@

Metadata

diff --git a/app/test/frontend/golden/pkg_show_page_retracted.html b/app/test/frontend/golden/pkg_show_page_retracted.html index 217a23da4d..3e6a7a02f2 100644 --- a/app/test/frontend/golden/pkg_show_page_retracted.html +++ b/app/test/frontend/golden/pkg_show_page_retracted.html @@ -168,21 +168,21 @@

Metadata

diff --git a/app/test/frontend/golden/pkg_show_page_retracted_non_retracted_version.html b/app/test/frontend/golden/pkg_show_page_retracted_non_retracted_version.html index a350470a6b..5dca8d285f 100644 --- a/app/test/frontend/golden/pkg_show_page_retracted_non_retracted_version.html +++ b/app/test/frontend/golden/pkg_show_page_retracted_non_retracted_version.html @@ -176,21 +176,21 @@

Metadata

diff --git a/app/test/frontend/golden/pkg_show_version_page.html b/app/test/frontend/golden/pkg_show_version_page.html index b2b4a49f3b..323525cbeb 100644 --- a/app/test/frontend/golden/pkg_show_version_page.html +++ b/app/test/frontend/golden/pkg_show_version_page.html @@ -186,21 +186,21 @@

Metadata

diff --git a/app/test/frontend/golden/pkg_versions_page.html b/app/test/frontend/golden/pkg_versions_page.html index 7e67aedf08..2989d4d6f0 100644 --- a/app/test/frontend/golden/pkg_versions_page.html +++ b/app/test/frontend/golden/pkg_versions_page.html @@ -186,21 +186,21 @@

Metadata

diff --git a/app/test/frontend/golden/publisher_activity_log_page.html b/app/test/frontend/golden/publisher_activity_log_page.html index 4f81c6cd14..eecfc705ca 100644 --- a/app/test/frontend/golden/publisher_activity_log_page.html +++ b/app/test/frontend/golden/publisher_activity_log_page.html @@ -141,13 +141,13 @@

example.com

diff --git a/app/test/frontend/golden/publisher_admin_page.html b/app/test/frontend/golden/publisher_admin_page.html index 45274df6ca..4ee000e959 100644 --- a/app/test/frontend/golden/publisher_admin_page.html +++ b/app/test/frontend/golden/publisher_admin_page.html @@ -141,12 +141,12 @@

example.com

diff --git a/app/test/frontend/golden/publisher_packages_page.html b/app/test/frontend/golden/publisher_packages_page.html index a9a9820686..c1f8dc0c03 100644 --- a/app/test/frontend/golden/publisher_packages_page.html +++ b/app/test/frontend/golden/publisher_packages_page.html @@ -141,15 +141,15 @@

example.com

diff --git a/app/test/frontend/golden/publisher_unlisted_packages_page.html b/app/test/frontend/golden/publisher_unlisted_packages_page.html index 0da42ece87..b40a88cdab 100644 --- a/app/test/frontend/golden/publisher_unlisted_packages_page.html +++ b/app/test/frontend/golden/publisher_unlisted_packages_page.html @@ -141,15 +141,15 @@

example.com

diff --git a/app/test/task/testdata/goldens/packages/oxygen.html b/app/test/task/testdata/goldens/packages/oxygen.html index e038e2919e..636443827f 100644 --- a/app/test/task/testdata/goldens/packages/oxygen.html +++ b/app/test/task/testdata/goldens/packages/oxygen.html @@ -178,21 +178,21 @@

Metadata

diff --git a/app/test/task/testdata/goldens/packages/oxygen/changelog.html b/app/test/task/testdata/goldens/packages/oxygen/changelog.html index ba1eb405df..f7fd979373 100644 --- a/app/test/task/testdata/goldens/packages/oxygen/changelog.html +++ b/app/test/task/testdata/goldens/packages/oxygen/changelog.html @@ -178,21 +178,21 @@

Metadata

diff --git a/app/test/task/testdata/goldens/packages/oxygen/example.html b/app/test/task/testdata/goldens/packages/oxygen/example.html index 6eadb4b339..b3d41067ef 100644 --- a/app/test/task/testdata/goldens/packages/oxygen/example.html +++ b/app/test/task/testdata/goldens/packages/oxygen/example.html @@ -178,21 +178,21 @@

Metadata

diff --git a/app/test/task/testdata/goldens/packages/oxygen/install.html b/app/test/task/testdata/goldens/packages/oxygen/install.html index fa800a91a9..67995406c1 100644 --- a/app/test/task/testdata/goldens/packages/oxygen/install.html +++ b/app/test/task/testdata/goldens/packages/oxygen/install.html @@ -178,21 +178,21 @@

Metadata

diff --git a/app/test/task/testdata/goldens/packages/oxygen/license.html b/app/test/task/testdata/goldens/packages/oxygen/license.html index a2f3d66685..63a4635229 100644 --- a/app/test/task/testdata/goldens/packages/oxygen/license.html +++ b/app/test/task/testdata/goldens/packages/oxygen/license.html @@ -178,24 +178,24 @@

Metadata

diff --git a/app/test/task/testdata/goldens/packages/oxygen/score.html b/app/test/task/testdata/goldens/packages/oxygen/score.html index fbad837bf2..5b551512a6 100644 --- a/app/test/task/testdata/goldens/packages/oxygen/score.html +++ b/app/test/task/testdata/goldens/packages/oxygen/score.html @@ -178,22 +178,22 @@

Metadata

diff --git a/app/test/task/testdata/goldens/packages/oxygen/versions.html b/app/test/task/testdata/goldens/packages/oxygen/versions.html index 45f179c5f2..895d300179 100644 --- a/app/test/task/testdata/goldens/packages/oxygen/versions.html +++ b/app/test/task/testdata/goldens/packages/oxygen/versions.html @@ -178,21 +178,21 @@

Metadata

diff --git a/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0.html b/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0.html index f4dd49f6a4..e4ad2f4488 100644 --- a/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0.html +++ b/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0.html @@ -182,21 +182,21 @@

Metadata

diff --git a/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/changelog.html b/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/changelog.html index 34befa1b06..884977ce27 100644 --- a/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/changelog.html +++ b/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/changelog.html @@ -182,21 +182,21 @@

Metadata

diff --git a/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/example.html b/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/example.html index 81e592aa95..45bddb0bb2 100644 --- a/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/example.html +++ b/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/example.html @@ -182,21 +182,21 @@

Metadata

diff --git a/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/install.html b/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/install.html index 371029463d..3c33767364 100644 --- a/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/install.html +++ b/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/install.html @@ -182,21 +182,21 @@

Metadata

diff --git a/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/license.html b/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/license.html index bac12a15a1..d1ec180dfa 100644 --- a/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/license.html +++ b/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/license.html @@ -182,24 +182,24 @@

Metadata

diff --git a/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/score.html b/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/score.html index 8662cfba9a..28aeeea2a1 100644 --- a/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/score.html +++ b/app/test/task/testdata/goldens/packages/oxygen/versions/1.0.0/score.html @@ -182,22 +182,22 @@

Metadata

diff --git a/app/test/task/testdata/goldens/packages/oxygen/versions/2.0.0.html b/app/test/task/testdata/goldens/packages/oxygen/versions/2.0.0.html index e038e2919e..636443827f 100644 --- a/app/test/task/testdata/goldens/packages/oxygen/versions/2.0.0.html +++ b/app/test/task/testdata/goldens/packages/oxygen/versions/2.0.0.html @@ -178,21 +178,21 @@

Metadata

diff --git a/pkg/_pub_shared/lib/validation/html/html_validation.dart b/pkg/_pub_shared/lib/validation/html/html_validation.dart index 240a1fda11..bec824eee7 100644 --- a/pkg/_pub_shared/lib/validation/html/html_validation.dart +++ b/pkg/_pub_shared/lib/validation/html/html_validation.dart @@ -156,6 +156,22 @@ void validateHtml(Node root) { 'Element has the same `title` and `aria-label` attribute, keep the `title`: ${elem.outerHtml}'); } } + + // "role"="" attributes should be on interactive components + final allowedForRole = {'a', 'form'}; + for (final elem in querySelectorAll('[role]')) { + final tag = elem.localName!; + final role = elem.attributes['role']; + // image elements may have presentation role + if (tag == 'img' && role == 'presentation') continue; + // interactive elements + if (elem.attributes.containsKey('tabindex')) continue; + if (allowedForRole.contains(tag)) continue; + // material components + if (tag == 'th' && role == 'columnheader') continue; + throw AssertionError( + '<$tag> tag should not have role attribute, found: ${elem.outerHtml}'); + } } /// "Google Search result usually points to the canonical page, unless one of