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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
use super::*;
/// The Sanitizer class.
/// [`Sanitizer`](https://developer.mozilla.org/en-US/docs/Web/API/Sanitizer)
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct Sanitizer {
inner: Any,
}
impl FromVal for Sanitizer {
fn from_val(v: &Any) -> Self {
Sanitizer {
inner: Any::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 Sanitizer {
type Target = Any;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl core::ops::DerefMut for Sanitizer {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<Any> for Sanitizer {
fn as_ref(&self) -> &Any {
&self.inner
}
}
impl AsMut<Any> for Sanitizer {
fn as_mut(&mut self) -> &mut Any {
&mut self.inner
}
}
impl From<Sanitizer> for Any {
fn from(s: Sanitizer) -> Any {
let handle = s.inner.as_handle();
core::mem::forget(s);
Any::take_ownership(handle)
}
}
impl From<&Sanitizer> for Any {
fn from(s: &Sanitizer) -> Any {
s.inner.clone().into()
}
}
jsbind::utils::impl_dyn_cast!(Sanitizer);
impl Sanitizer {
/// The `new Sanitizer(..)` constructor, creating a new Sanitizer instance
pub fn new() -> Sanitizer {
Self {
inner: Any::global("Sanitizer").new(&[]).as_::<Any>(),
}
}
}
impl Sanitizer {
/// The `new Sanitizer(..)` constructor, creating a new Sanitizer instance
pub fn new_with_configuration(configuration: &Any) -> Sanitizer {
Self {
inner: Any::global("Sanitizer")
.new(&[configuration.into()])
.as_::<Any>(),
}
}
}
impl Sanitizer {
/// The get method.
/// [`Sanitizer.get`](https://developer.mozilla.org/en-US/docs/Web/API/Sanitizer/get)
pub fn get(&self) -> SanitizerConfig {
self.inner.call("get", &[]).as_::<SanitizerConfig>()
}
}
impl Sanitizer {
/// The allowElement method.
/// [`Sanitizer.allowElement`](https://developer.mozilla.org/en-US/docs/Web/API/Sanitizer/allowElement)
pub fn allow_element(&self, element: &Any) -> Undefined {
self.inner
.call("allowElement", &[element.into()])
.as_::<Undefined>()
}
}
impl Sanitizer {
/// The removeElement method.
/// [`Sanitizer.removeElement`](https://developer.mozilla.org/en-US/docs/Web/API/Sanitizer/removeElement)
pub fn remove_element(&self, element: &Any) -> Undefined {
self.inner
.call("removeElement", &[element.into()])
.as_::<Undefined>()
}
}
impl Sanitizer {
/// The replaceElementWithChildren method.
/// [`Sanitizer.replaceElementWithChildren`](https://developer.mozilla.org/en-US/docs/Web/API/Sanitizer/replaceElementWithChildren)
pub fn replace_element_with_children(&self, element: &Any) -> Undefined {
self.inner
.call("replaceElementWithChildren", &[element.into()])
.as_::<Undefined>()
}
}
impl Sanitizer {
/// The allowAttribute method.
/// [`Sanitizer.allowAttribute`](https://developer.mozilla.org/en-US/docs/Web/API/Sanitizer/allowAttribute)
pub fn allow_attribute(&self, attribute: &Any) -> Undefined {
self.inner
.call("allowAttribute", &[attribute.into()])
.as_::<Undefined>()
}
}
impl Sanitizer {
/// The removeAttribute method.
/// [`Sanitizer.removeAttribute`](https://developer.mozilla.org/en-US/docs/Web/API/Sanitizer/removeAttribute)
pub fn remove_attribute(&self, attribute: &Any) -> Undefined {
self.inner
.call("removeAttribute", &[attribute.into()])
.as_::<Undefined>()
}
}
impl Sanitizer {
/// The setComments method.
/// [`Sanitizer.setComments`](https://developer.mozilla.org/en-US/docs/Web/API/Sanitizer/setComments)
pub fn set_comments(&self, allow: bool) -> Undefined {
self.inner
.call("setComments", &[allow.into()])
.as_::<Undefined>()
}
}
impl Sanitizer {
/// The setDataAttributes method.
/// [`Sanitizer.setDataAttributes`](https://developer.mozilla.org/en-US/docs/Web/API/Sanitizer/setDataAttributes)
pub fn set_data_attributes(&self, allow: bool) -> Undefined {
self.inner
.call("setDataAttributes", &[allow.into()])
.as_::<Undefined>()
}
}
impl Sanitizer {
/// The removeUnsafe method.
/// [`Sanitizer.removeUnsafe`](https://developer.mozilla.org/en-US/docs/Web/API/Sanitizer/removeUnsafe)
pub fn remove_unsafe(&self) -> Undefined {
self.inner.call("removeUnsafe", &[]).as_::<Undefined>()
}
}