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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
use super::*;
/// The Location class.
/// [`Location`](https://developer.mozilla.org/en-US/docs/Web/API/Location)
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct Location {
inner: Any,
}
impl FromVal for Location {
fn from_val(v: &Any) -> Self {
Location {
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 Location {
type Target = Any;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl core::ops::DerefMut for Location {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<Any> for Location {
fn as_ref(&self) -> &Any {
&self.inner
}
}
impl AsMut<Any> for Location {
fn as_mut(&mut self) -> &mut Any {
&mut self.inner
}
}
impl From<Location> for Any {
fn from(s: Location) -> Any {
let handle = s.inner.as_handle();
core::mem::forget(s);
Any::take_ownership(handle)
}
}
impl From<&Location> for Any {
fn from(s: &Location) -> Any {
s.inner.clone().into()
}
}
jsbind::utils::impl_dyn_cast!(Location);
impl Location {
/// Getter of the `href` attribute.
/// [`Location.href`](https://developer.mozilla.org/en-US/docs/Web/API/Location/href)
pub fn href(&self) -> JsString {
self.inner.get("href").as_::<JsString>()
}
/// Setter of the `href` attribute.
/// [`Location.href`](https://developer.mozilla.org/en-US/docs/Web/API/Location/href)
pub fn set_href(&mut self, value: &JsString) {
self.inner.set("href", value);
}
}
impl Location {
/// Getter of the `origin` attribute.
/// [`Location.origin`](https://developer.mozilla.org/en-US/docs/Web/API/Location/origin)
pub fn origin(&self) -> JsString {
self.inner.get("origin").as_::<JsString>()
}
}
impl Location {
/// Getter of the `protocol` attribute.
/// [`Location.protocol`](https://developer.mozilla.org/en-US/docs/Web/API/Location/protocol)
pub fn protocol(&self) -> JsString {
self.inner.get("protocol").as_::<JsString>()
}
/// Setter of the `protocol` attribute.
/// [`Location.protocol`](https://developer.mozilla.org/en-US/docs/Web/API/Location/protocol)
pub fn set_protocol(&mut self, value: &JsString) {
self.inner.set("protocol", value);
}
}
impl Location {
/// Getter of the `host` attribute.
/// [`Location.host`](https://developer.mozilla.org/en-US/docs/Web/API/Location/host)
pub fn host(&self) -> JsString {
self.inner.get("host").as_::<JsString>()
}
/// Setter of the `host` attribute.
/// [`Location.host`](https://developer.mozilla.org/en-US/docs/Web/API/Location/host)
pub fn set_host(&mut self, value: &JsString) {
self.inner.set("host", value);
}
}
impl Location {
/// Getter of the `hostname` attribute.
/// [`Location.hostname`](https://developer.mozilla.org/en-US/docs/Web/API/Location/hostname)
pub fn hostname(&self) -> JsString {
self.inner.get("hostname").as_::<JsString>()
}
/// Setter of the `hostname` attribute.
/// [`Location.hostname`](https://developer.mozilla.org/en-US/docs/Web/API/Location/hostname)
pub fn set_hostname(&mut self, value: &JsString) {
self.inner.set("hostname", value);
}
}
impl Location {
/// Getter of the `port` attribute.
/// [`Location.port`](https://developer.mozilla.org/en-US/docs/Web/API/Location/port)
pub fn port(&self) -> JsString {
self.inner.get("port").as_::<JsString>()
}
/// Setter of the `port` attribute.
/// [`Location.port`](https://developer.mozilla.org/en-US/docs/Web/API/Location/port)
pub fn set_port(&mut self, value: &JsString) {
self.inner.set("port", value);
}
}
impl Location {
/// Getter of the `pathname` attribute.
/// [`Location.pathname`](https://developer.mozilla.org/en-US/docs/Web/API/Location/pathname)
pub fn pathname(&self) -> JsString {
self.inner.get("pathname").as_::<JsString>()
}
/// Setter of the `pathname` attribute.
/// [`Location.pathname`](https://developer.mozilla.org/en-US/docs/Web/API/Location/pathname)
pub fn set_pathname(&mut self, value: &JsString) {
self.inner.set("pathname", value);
}
}
impl Location {
/// Getter of the `search` attribute.
/// [`Location.search`](https://developer.mozilla.org/en-US/docs/Web/API/Location/search)
pub fn search(&self) -> JsString {
self.inner.get("search").as_::<JsString>()
}
/// Setter of the `search` attribute.
/// [`Location.search`](https://developer.mozilla.org/en-US/docs/Web/API/Location/search)
pub fn set_search(&mut self, value: &JsString) {
self.inner.set("search", value);
}
}
impl Location {
/// Getter of the `hash` attribute.
/// [`Location.hash`](https://developer.mozilla.org/en-US/docs/Web/API/Location/hash)
pub fn hash(&self) -> JsString {
self.inner.get("hash").as_::<JsString>()
}
/// Setter of the `hash` attribute.
/// [`Location.hash`](https://developer.mozilla.org/en-US/docs/Web/API/Location/hash)
pub fn set_hash(&mut self, value: &JsString) {
self.inner.set("hash", value);
}
}
impl Location {
/// Getter of the `ancestorOrigins` attribute.
/// [`Location.ancestorOrigins`](https://developer.mozilla.org/en-US/docs/Web/API/Location/ancestorOrigins)
pub fn ancestor_origins(&self) -> DOMStringList {
self.inner.get("ancestorOrigins").as_::<DOMStringList>()
}
}
impl Location {
/// The assign method.
/// [`Location.assign`](https://developer.mozilla.org/en-US/docs/Web/API/Location/assign)
pub fn assign(&self, url: &JsString) -> Undefined {
self.inner.call("assign", &[url.into()]).as_::<Undefined>()
}
}
impl Location {
/// The replace method.
/// [`Location.replace`](https://developer.mozilla.org/en-US/docs/Web/API/Location/replace)
pub fn replace(&self, url: &JsString) -> Undefined {
self.inner.call("replace", &[url.into()]).as_::<Undefined>()
}
}
impl Location {
/// The reload method.
/// [`Location.reload`](https://developer.mozilla.org/en-US/docs/Web/API/Location/reload)
pub fn reload(&self) -> Undefined {
self.inner.call("reload", &[]).as_::<Undefined>()
}
}