Skip to content

Commit 7304d04

Browse files
committed
feat!: AttrKindOfSpellcheck
1 parent aa09038 commit 7304d04

File tree

13 files changed

+58
-65
lines changed

13 files changed

+58
-65
lines changed

packages/frender-attr-value/src/html.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ mod content_editable;
22
pub use content_editable::AttrKindOfContentEditable;
33

44
mod spellcheck;
5-
pub use spellcheck::Spellcheck;
5+
pub use spellcheck::AttrKindOfSpellcheck;
66

77
fn bool_to_str(this: bool) -> &'static str {
88
if this {

packages/frender-attr-value/src/html/spellcheck.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ mod ssr;
99

1010
/// See html attribute [spellcheck](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/spellcheck).
1111
///
12-
/// ## Types that impl [`AttrValue<Spellcheck>`]
12+
/// ## Types that impl [`AttrValue<AttrKindOfSpellcheck>`]
1313
///
14-
/// - [`Spellcheck`]
1514
/// - [`bool`]
1615
///
1716
/// `true` is mapped to `"true". `false` is mapped to "false"`.
@@ -20,18 +19,11 @@ mod ssr;
2019
///
2120
/// An empty string, which is the same as `true`.
2221
///
23-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
24-
pub struct Spellcheck(pub bool);
22+
pub enum AttrKindOfSpellcheck {}
2523

26-
impl Spellcheck {
27-
/// empty string or true, which indicates that the element should be, if possible, checked for spelling errors
28-
pub const EMPTY: Self = Self(true);
24+
impl AttrValueKind for AttrKindOfSpellcheck {
25+
type AttrValue<'a> = bool;
2926
}
3027

31-
impl AttrValueKind for Spellcheck {
32-
type AttrValue<'a> = Spellcheck;
33-
}
34-
35-
impl AttrValue<Spellcheck> for Spellcheck {}
36-
impl AttrValue<Spellcheck> for bool {}
37-
impl AttrValue<Spellcheck> for Empty {}
28+
impl AttrValue<AttrKindOfSpellcheck> for bool {}
29+
impl AttrValue<AttrKindOfSpellcheck> for Empty {}
Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,25 @@
11
use crate::{
2-
csr::CsrAttrValue, html::Spellcheck, impl_csr_attr_value_for_unit_struct,
2+
csr::CsrAttrValue, html::AttrKindOfSpellcheck, impl_csr_attr_value_for_unit_struct,
33
impl_csr_attr_value_with_cache,
44
};
55

6-
impl CsrAttrValue<Spellcheck> for Spellcheck {
7-
type State = bool;
8-
9-
impl_csr_attr_value_with_cache!(
10-
kind![Spellcheck],
11-
set = |this| this,
12-
into_cache = this.0,
13-
eq = |this, cache| this.0 == *cache,
14-
);
15-
}
16-
17-
impl CsrAttrValue<Spellcheck> for bool {
6+
impl CsrAttrValue<AttrKindOfSpellcheck> for bool {
187
type State = Self;
198

209
impl_csr_attr_value_with_cache!(
21-
kind![Spellcheck],
22-
set = |this| Spellcheck(this),
10+
kind![AttrKindOfSpellcheck],
11+
set = |this| this,
2312
eq = Self::eq,
2413
);
2514
}
2615

2716
use frender_common::Empty;
2817

29-
impl CsrAttrValue<Spellcheck> for Empty {
30-
impl_csr_attr_value_for_unit_struct!((Spellcheck::EMPTY) as Spellcheck);
18+
impl CsrAttrValue<AttrKindOfSpellcheck> for Empty {
19+
impl_csr_attr_value_for_unit_struct!((AttrKindOfSpellcheck::EMPTY) as AttrKindOfSpellcheck);
20+
}
21+
22+
impl AttrKindOfSpellcheck {
23+
/// empty string or true, which indicates that the element should be, if possible, checked for spelling errors
24+
pub(crate) const EMPTY: bool = true;
3125
}

packages/frender-attr-value/src/html/spellcheck/ssr.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,9 @@ use frender_common::Empty;
22

33
use crate::{html::bool_to_str, ssr::SsrAttrValue, AttrKindOfStr};
44

5-
use super::Spellcheck;
5+
use super::AttrKindOfSpellcheck;
66

7-
impl SsrAttrValue<Spellcheck> for Spellcheck {
8-
type HtmlAttributeValue = <bool as SsrAttrValue<Spellcheck>>::HtmlAttributeValue;
9-
10-
fn maybe_into_html_attribute_value(this: Self) -> Option<Self::HtmlAttributeValue> {
11-
SsrAttrValue::<Spellcheck>::maybe_into_html_attribute_value(this.0)
12-
}
13-
}
14-
15-
impl SsrAttrValue<Spellcheck> for bool {
7+
impl SsrAttrValue<AttrKindOfSpellcheck> for bool {
168
type HtmlAttributeValue = <&'static str as SsrAttrValue<AttrKindOfStr>>::HtmlAttributeValue;
179

1810
fn maybe_into_html_attribute_value(this: Self) -> Option<Self::HtmlAttributeValue> {
@@ -22,7 +14,7 @@ impl SsrAttrValue<Spellcheck> for bool {
2214
}
2315
}
2416

25-
impl SsrAttrValue<Spellcheck> for Empty {
17+
impl SsrAttrValue<AttrKindOfSpellcheck> for Empty {
2618
type HtmlAttributeValue = async_str_iter::empty::Empty;
2719

2820
fn maybe_into_html_attribute_value(Self: Self) -> Option<Self::HtmlAttributeValue> {

packages/frender-dom-values/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub mod attr_value {
5454
};
5555

5656
#[cfg(feature = "html")]
57-
pub use frender_attr_value::html::{AttrKindOfContentEditable, Spellcheck};
57+
pub use frender_attr_value::html::{AttrKindOfContentEditable, AttrKindOfSpellcheck};
5858

5959
#[cfg(feature = "csr")]
6060
pub use frender_attr_value::csr::CsrAttrValue;

packages/frender-html/src/attr_value/csr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::marker::PhantomData;
22

33
use frender_attr_value::{
44
csr::{CsrAttrValue, UpdateAttrValue},
5-
html::{AttrKindOfContentEditable, Spellcheck},
5+
html::{AttrKindOfContentEditable, AttrKindOfSpellcheck},
66
AttrKindOfStr, AttrValueKind,
77
};
88
use frender_common::convert::FromMut as _;
@@ -147,7 +147,7 @@ where
147147
}
148148

149149
trait SimpleAttrValueKindRemoveAttr: AttrValueKind {}
150-
impl SimpleAttrValueKindRemoveAttr for Spellcheck {}
150+
impl SimpleAttrValueKindRemoveAttr for AttrKindOfSpellcheck {}
151151
impl SimpleAttrValueKindRemoveAttr for AttrKindOfContentEditable {}
152152
impl SimpleAttrValueKindRemoveAttr for AttrKindOfStr {}
153153
impl SimpleAttrValueKindRemoveAttr for i32 {}

packages/frender-html/src/element_proxy_attrs/csr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ pub(crate) mod macros {
315315
}
316316
};
317317
(
318-
update_with($set_attribute_ident:ident, custom_type!($custom_type:ty), impl_with! $impl_with:tt $(,)?)
318+
update_with($set_attribute_ident:ident, custom_type!($custom_type:ty) $(, impl_with! $impl_with:tt $(,)?)?)
319319
value($value:ident)
320320
type($maybe_ty:ty)
321321
trait_name($trait_name:ident $($only_for_types:tt)?)

packages/frender-html/src/html.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![allow(warnings)] // TODO: remove
22

33
use frender_attr_value::{
4-
html::{AttrKindOfContentEditable, Spellcheck},
4+
html::{AttrKindOfContentEditable, AttrKindOfSpellcheck},
55
AttrKindOfStr,
66
};
77
#[cfg(feature = "csr")]
@@ -891,17 +891,8 @@ crate::macros::def_intrinsic_component_props!(
891891
fn nonce(value: attr_value![&str]);
892892
fn role(value: attr_value![&str]);
893893
fn slot(value: attr_value![&str]);
894-
fn spellcheck(value: attr_value![Spellcheck]) {
895-
update_with!(
896-
//
897-
set_spellcheck,
898-
custom_type!(bool),
899-
impl_with!(
900-
//
901-
dom_api_value_from_value = |Spellcheck(v)| v,
902-
update = |element, renderer| element.set_spellcheck(renderer, value),
903-
),
904-
);
894+
fn spellcheck(value: attr_value![AttrKindOfSpellcheck]) {
895+
update_with!(set_spellcheck, custom_type!(bool));
905896
}
906897
fn style(value: bounds![Style]);
907898
fn tab_index(value: attr_value![i32]) {

packages/frender-html/src/html/props.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,8 +802,8 @@ pub mod HtmlElement {
802802
impl<V: frender_attr_value::AttrValue<AttrKindOfStr>> Property for slot<V> {
803803
type PropertyMarker = _prop_markers::slot;
804804
}
805-
pub struct spellcheck<V: frender_attr_value::AttrValue<Spellcheck>>(pub V);
806-
impl<V: frender_attr_value::AttrValue<Spellcheck>> Property for spellcheck<V> {
805+
pub struct spellcheck<V: frender_attr_value::AttrValue<AttrKindOfSpellcheck>>(pub V);
806+
impl<V: frender_attr_value::AttrValue<AttrKindOfSpellcheck>> Property for spellcheck<V> {
807807
type PropertyMarker = _prop_markers::spellcheck;
808808
}
809809
pub struct style<V: Style::Bounds>(pub V);

packages/frender-html/src/html/props_builders.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,7 @@ const _: () = {
13771377
}
13781378
}
13791379
impl<M: AllowAttribute<prop_markers::spellcheck>, C, A, P> Intrinsic<M, C, A, P> {
1380-
pub fn spellcheck<V: frender_attr_value::AttrValue<Spellcheck>>(self, value: V) -> Intrinsic<M, C, (A, props::spellcheck<V>), P> {
1380+
pub fn spellcheck<V: frender_attr_value::AttrValue<AttrKindOfSpellcheck>>(self, value: V) -> Intrinsic<M, C, (A, props::spellcheck<V>), P> {
13811381
Self::with_attribute_appended(self, props::spellcheck(value))
13821382
}
13831383
}

0 commit comments

Comments
 (0)