Skip to content

Commit 5de1148

Browse files
fix(dom): remove option from get_by and find_by queries
1 parent ecccf11 commit 5de1148

16 files changed

Lines changed: 70 additions & 115 deletions

book/src/core/user-actions/firing-events.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ event.set_bubbles(true);
2626
event.set_cancelable(true);
2727
2828
fire_event(
29-
get_by_text(&container, "Submit")
30-
.expect("Get should succeed.")
31-
.expect("Get should return an element."),
29+
get_by_text(&container, "Submit").expect("Get should succeed."),
3230
&event,
3331
).expect("Event should be fired.");
3432
```

packages/dom/src/get_queries_for_element.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,29 @@ macro_rules! queries_for_element {
1919
($(($name:ident, $matcher_type:ty, $options_type:ty)),*,) => {
2020
paste::paste! {
2121
impl BoundFunctions {
22-
$(pub fn [< find_by_ $name >]<M: Into<$matcher_type>>(
22+
$(pub async fn [< find_by_ $name >]<M: Into<$matcher_type>>(
2323
&self,
2424
matcher: M,
2525
options: $options_type,
2626
wait_for_options: WaitForOptions,
27-
) -> Result<Option<HtmlElement>, QueryError> {
28-
[< find_by_ $name >](&self.element, matcher, options, wait_for_options)
27+
) -> Result<HtmlElement, QueryError> {
28+
[< find_by_ $name >](&self.element, matcher, options, wait_for_options).await
2929
})*
3030

31-
$(pub fn [< find_all_by_ $name >]<M: Into<$matcher_type>>(
31+
$(pub async fn [< find_all_by_ $name >]<M: Into<$matcher_type>>(
3232
&self,
3333
matcher: M,
3434
options: $options_type,
3535
wait_for_options: WaitForOptions,
3636
) -> Result<Vec<HtmlElement>, QueryError> {
37-
[< find_all_by_ $name >](&self.element, matcher, options, wait_for_options)
37+
[< find_all_by_ $name >](&self.element, matcher, options, wait_for_options).await
3838
})*
3939

4040
$(pub fn [< get_by_ $name >]<M: Into<$matcher_type>>(
4141
&self,
4242
matcher: M,
4343
options: $options_type,
44-
) -> Result<Option<HtmlElement>, QueryError> {
44+
) -> Result<HtmlElement, QueryError> {
4545
[< get_by_ $name >](&self.element, matcher, options)
4646
})*
4747

packages/dom/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub use config::{configure, get_config};
2020
pub use error::QueryError;
2121
pub use events::*;
2222
pub use get_node_text::*;
23+
pub use get_queries_for_element::get_queries_for_element as within;
2324
pub use get_queries_for_element::*;
2425
pub use matches::get_default_normalizer;
2526
pub use pretty_dom::*;
@@ -34,4 +35,5 @@ pub use types::*;
3435
pub use wait_for::*;
3536

3637
// TODO: Export useful types from `aria_query`.
38+
#[doc(no_inline)]
3739
pub use aria_query::{AriaRole, AriaRoleDefinitionKey};

packages/dom/src/queries/alt_text.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{
88
types::{Matcher, MatcherOptions},
99
};
1010

11-
pub fn _query_all_by_alt_text<M: Into<Matcher>>(
11+
pub(crate) fn _query_all_by_alt_text<M: Into<Matcher>>(
1212
container: &HtmlElement,
1313
alt: M,
1414
options: MatcherOptions,

packages/dom/src/queries/display_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{
1010
util::{html_collection_to_vec, node_list_to_vec},
1111
};
1212

13-
pub fn _query_all_by_display_value<M: Into<Matcher>>(
13+
pub(crate) fn _query_all_by_display_value<M: Into<Matcher>>(
1414
container: &HtmlElement,
1515
value: M,
1616
options: MatcherOptions,

packages/dom/src/queries/label_text.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{
1010
util::node_list_to_vec,
1111
};
1212

13-
pub fn _query_all_by_label_text<M: Into<Matcher>>(
13+
pub(crate) fn _query_all_by_label_text<M: Into<Matcher>>(
1414
container: &HtmlElement,
1515
text: M,
1616
options: SelectorMatcherOptions,

packages/dom/src/queries/placeholder_text.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::{
77
types::{Matcher, MatcherOptions},
88
};
99

10-
pub fn _query_all_by_placeholder_text<M: Into<Matcher>>(
10+
pub(crate) fn _query_all_by_placeholder_text<M: Into<Matcher>>(
1111
container: &HtmlElement,
1212
text: M,
1313
options: MatcherOptions,

packages/dom/src/queries/role.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::{
2121
util::node_list_to_vec,
2222
};
2323

24-
pub fn _query_all_by_role<M: Into<ByRoleMatcher>>(
24+
pub(crate) fn _query_all_by_role<M: Into<ByRoleMatcher>>(
2525
container: &HtmlElement,
2626
role: M,
2727
options: ByRoleOptions,

packages/dom/src/queries/test_id.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn get_test_id_attribute() -> String {
1212
get_config().test_id_attribute
1313
}
1414

15-
pub fn _query_all_by_test_id<M: Into<Matcher>>(
15+
pub(crate) fn _query_all_by_test_id<M: Into<Matcher>>(
1616
container: &HtmlElement,
1717
id: M,
1818
options: MatcherOptions,

packages/dom/src/queries/text.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{
1010
util::node_list_to_vec,
1111
};
1212

13-
pub fn _query_all_by_text<M: Into<Matcher>>(
13+
pub(crate) fn _query_all_by_text<M: Into<Matcher>>(
1414
container: &HtmlElement,
1515
text: M,
1616
options: SelectorMatcherOptions,

0 commit comments

Comments
 (0)