Skip to content

Commit 12e227d

Browse files
Add dom-accessibility-api
1 parent ce67702 commit 12e227d

5 files changed

Lines changed: 24 additions & 27 deletions

File tree

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/dom/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ version.workspace = true
1111

1212
[dependencies]
1313
aria-query = "0.0.3"
14+
dom-accessibility-api = "0.0.2"
1415
log.workspace = true
1516
paste = "1.0.15"
1617
pretty-format = { path = "../pretty-format", version = "0.0.1" }

packages/dom/src/config.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use crate::{
99
static CONFIG: LazyLock<Arc<Mutex<Config>>> = LazyLock::new(|| {
1010
Arc::new(Mutex::new(Config {
1111
test_id_attribute: "data-testid".into(),
12-
computed_style_supports_pseudo_elements: false,
1312
default_hidden: false,
1413
default_ignore: "script, style".into(),
1514
show_original_stack_trace: false,

packages/dom/src/queries/role.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
use std::collections::HashSet;
22

33
use aria_query::{AriaProperty, AriaRole, ROLES, ROLE_ELEMENTS};
4-
use web_sys::{Element, HtmlElement};
4+
use dom_accessibility_api::{
5+
compute_accessible_description, compute_accessible_name, ComputeTextAlternativeOptions,
6+
};
7+
use web_sys::HtmlElement;
58

69
use crate::{
710
build_queries,
@@ -18,14 +21,6 @@ use crate::{
1821
util::node_list_to_vec,
1922
};
2023

21-
fn compute_accessibe_name(_element: &Element) -> String {
22-
todo!("port dom-accessibility-api and import compute_accessibe_name")
23-
}
24-
25-
fn compute_accessibe_description(_element: &Element) -> String {
26-
todo!("port dom-accessibility-api and import compute_accessibe_description")
27-
}
28-
2924
pub fn _query_all_by_role<M: Into<ByRoleMatcher>>(
3025
container: &HtmlElement,
3126
role: M,
@@ -261,7 +256,10 @@ pub fn _query_all_by_role<M: Into<ByRoleMatcher>>(
261256
let normalizer = |text| text;
262257

263258
matches(
264-
Some(compute_accessibe_name(element)),
259+
Some(compute_accessible_name(
260+
element,
261+
ComputeTextAlternativeOptions::default(),
262+
)),
265263
Some(element),
266264
name,
267265
&normalizer,
@@ -276,7 +274,10 @@ pub fn _query_all_by_role<M: Into<ByRoleMatcher>>(
276274
let normalizer = |text| text;
277275

278276
matches(
279-
Some(compute_accessibe_description(element)),
277+
Some(compute_accessible_description(
278+
element,
279+
ComputeTextAlternativeOptions::default(),
280+
)),
280281
Some(element),
281282
description,
282283
&normalizer,

packages/dom/src/types/config.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ pub type GetElementErrorFn = dyn Fn(Option<String>, Element) -> QueryError + Sen
1010
pub struct Config {
1111
pub test_id_attribute: String,
1212
// TODO
13-
pub computed_style_supports_pseudo_elements: bool,
1413
/// Default value for the `hidden` option in `by_role` queries.
1514
pub default_hidden: bool,
1615
/// Default value for the `ignore` option in `by_text` queries.
@@ -28,11 +27,6 @@ impl Config {
2827
if let Some(test_id_attribute) = other.test_id_attribute {
2928
self.test_id_attribute = test_id_attribute;
3029
}
31-
if let Some(computed_style_supports_pseudo_elements) =
32-
other.computed_style_supports_pseudo_elements
33-
{
34-
self.computed_style_supports_pseudo_elements = computed_style_supports_pseudo_elements;
35-
}
3630
if let Some(default_hidden) = other.default_hidden {
3731
self.default_hidden = default_hidden;
3832
}
@@ -55,7 +49,6 @@ impl Config {
5549
pub struct PartialConfig {
5650
pub test_id_attribute: Option<String>,
5751
// TODO
58-
pub computed_style_supports_pseudo_elements: Option<bool>,
5952
/// Default value for the `hidden` option in `by_role` queries.
6053
pub default_hidden: Option<bool>,
6154
/// Default value for the `ignore` option in `by_text` queries.
@@ -74,11 +67,6 @@ impl PartialConfig {
7467
self
7568
}
7669

77-
pub fn computed_style_supports_pseudo_elements(mut self, value: bool) -> Self {
78-
self.computed_style_supports_pseudo_elements = Some(value);
79-
self
80-
}
81-
8270
pub fn default_hidden(mut self, value: bool) -> Self {
8371
self.default_hidden = Some(value);
8472
self
@@ -109,9 +97,6 @@ impl From<&Config> for PartialConfig {
10997
fn from(value: &Config) -> Self {
11098
Self {
11199
test_id_attribute: Some(value.test_id_attribute.clone()),
112-
computed_style_supports_pseudo_elements: Some(
113-
value.computed_style_supports_pseudo_elements,
114-
),
115100
default_hidden: Some(value.default_hidden),
116101
default_ignore: Some(value.default_ignore.clone()),
117102
show_original_stack_trace: Some(value.show_original_stack_trace),

0 commit comments

Comments
 (0)