1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
use super::*;
/// The Attr class.
/// [`Attr`](https://developer.mozilla.org/en-US/docs/Web/API/Attr)
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct Attr {
inner: Node,
}
impl FromVal for Attr {
fn from_val(v: &Any) -> Self {
Attr {
inner: Node::from_val(v),
}
}
fn take_ownership(v: AnyHandle) -> Self {
Self::from_val(&Any::take_ownership(v))
}
fn as_handle(&self) -> AnyHandle {
self.inner.as_handle()
}
}
impl core::ops::Deref for Attr {
type Target = Node;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl core::ops::DerefMut for Attr {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<Any> for Attr {
fn as_ref(&self) -> &Any {
&self.inner
}
}
impl AsMut<Any> for Attr {
fn as_mut(&mut self) -> &mut Any {
&mut self.inner
}
}
impl From<Attr> for Any {
fn from(s: Attr) -> Any {
let handle = s.inner.as_handle();
core::mem::forget(s);
Any::take_ownership(handle)
}
}
impl From<&Attr> for Any {
fn from(s: &Attr) -> Any {
s.inner.clone().into()
}
}
jsbind::utils::impl_dyn_cast!(Attr);
impl Attr {
/// Getter of the `namespaceURI` attribute.
/// [`Attr.namespaceURI`](https://developer.mozilla.org/en-US/docs/Web/API/Attr/namespaceURI)
pub fn namespace_uri(&self) -> JsString {
self.inner.get("namespaceURI").as_::<JsString>()
}
}
impl Attr {
/// Getter of the `prefix` attribute.
/// [`Attr.prefix`](https://developer.mozilla.org/en-US/docs/Web/API/Attr/prefix)
pub fn prefix(&self) -> JsString {
self.inner.get("prefix").as_::<JsString>()
}
}
impl Attr {
/// Getter of the `localName` attribute.
/// [`Attr.localName`](https://developer.mozilla.org/en-US/docs/Web/API/Attr/localName)
pub fn local_name(&self) -> JsString {
self.inner.get("localName").as_::<JsString>()
}
}
impl Attr {
/// Getter of the `name` attribute.
/// [`Attr.name`](https://developer.mozilla.org/en-US/docs/Web/API/Attr/name)
pub fn name(&self) -> JsString {
self.inner.get("name").as_::<JsString>()
}
}
impl Attr {
/// Getter of the `value` attribute.
/// [`Attr.value`](https://developer.mozilla.org/en-US/docs/Web/API/Attr/value)
pub fn value(&self) -> JsString {
self.inner.get("value").as_::<JsString>()
}
/// Setter of the `value` attribute.
/// [`Attr.value`](https://developer.mozilla.org/en-US/docs/Web/API/Attr/value)
pub fn set_value(&mut self, value: &JsString) {
self.inner.set("value", value);
}
}
impl Attr {
/// Getter of the `ownerElement` attribute.
/// [`Attr.ownerElement`](https://developer.mozilla.org/en-US/docs/Web/API/Attr/ownerElement)
pub fn owner_element(&self) -> Element {
self.inner.get("ownerElement").as_::<Element>()
}
}
impl Attr {
/// Getter of the `specified` attribute.
/// [`Attr.specified`](https://developer.mozilla.org/en-US/docs/Web/API/Attr/specified)
pub fn specified(&self) -> bool {
self.inner.get("specified").as_::<bool>()
}
}