Skip to content

Commit b15e44a

Browse files
Remove web_sys references
1 parent 0c62c25 commit b15e44a

File tree

12 files changed

+7
-26
lines changed

12 files changed

+7
-26
lines changed

packages/yew-router/src/route.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ use std::{
99
};
1010

1111
/// Any state that can be used in the router agent must meet the criteria of this trait.
12-
#[cfg(all(feature = "service", feature = "web_sys"))]
1312
pub trait RouteState: Serialize + DeserializeOwned + Debug + Clone + Default + 'static {}
14-
#[cfg(all(feature = "service", feature = "web_sys"))]
1513
impl<T> RouteState for T where T: Serialize + DeserializeOwned + Debug + Clone + Default + 'static {}
1614

1715
/// The representation of a route, segmented into different sections for easy access.

packages/yew/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ rmp-serde = "0.15.0"
121121
bincode = "1"
122122

123123
[features]
124-
default = ["services", "agent", "web_sys"]
124+
default = ["web_sys", "services", "agent"]
125125
web_sys = [
126126
"console_error_panic_hook",
127127
"gloo",

packages/yew/src/agent/worker/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ where
7171
worker.post_message_vec(msg);
7272
}
7373

74-
#[cfg(feature = "web_sys")]
7574
fn worker_new(name_of_resource: &str, is_module: bool) -> Worker {
7675
let origin = utils::origin().unwrap();
7776
let script_url = format!("{}/{}", origin, name_of_resource);
@@ -105,19 +104,16 @@ fn worker_new(name_of_resource: &str, is_module: bool) -> Worker {
105104
}
106105
}
107106

108-
#[cfg(feature = "web_sys")]
109107
fn worker_self() -> DedicatedWorkerGlobalScope {
110108
JsValue::from(js_sys::global()).into()
111109
}
112110

113-
#[cfg(feature = "web_sys")]
114111
trait WorkerExt {
115112
fn set_onmessage_closure(&self, handler: impl 'static + Fn(Vec<u8>));
116113

117114
fn post_message_vec(&self, data: Vec<u8>);
118115
}
119116

120-
#[cfg(feature = "web_sys")]
121117
macro_rules! worker_ext_impl {
122118
($($type:ident),+) => {$(
123119
impl WorkerExt for $type {
@@ -139,7 +135,6 @@ macro_rules! worker_ext_impl {
139135
)+};
140136
}
141137

142-
#[cfg(feature = "web_sys")]
143138
worker_ext_impl! {
144139
Worker, DedicatedWorkerGlobalScope
145140
}

packages/yew/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ pub mod agent;
277277
#[cfg(feature = "services")]
278278
pub mod services;
279279

280-
#[cfg(feature = "web_sys")]
281280
pub use web_sys;
282281

283282
/// The module that contains all events available in the framework.

packages/yew/src/services/fetch.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ mod tests {
2121
use crate::callback::{test_util::CallbackFuture, Callback};
2222
use crate::format::{Json, Nothing};
2323
use crate::utils;
24-
#[cfg(feature = "web_sys")]
2524
use ::web_sys::ReferrerPolicy;
2625
use serde::Deserialize;
2726
use ssri::Integrity;

packages/yew/src/services/resize.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ impl WindowDimensions {
3333
pub fn get_dimensions(window: &Window) -> Self {
3434
let width = window.inner_width();
3535
let height = window.inner_height();
36-
#[cfg(feature = "web_sys")]
3736
let (width, height) = {
3837
(
3938
width.unwrap().as_f64().unwrap() as _,

packages/yew/src/services/websocket.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,10 @@ pub enum WebSocketError {
3434
pub struct WebSocketTask {
3535
ws: WebSocket,
3636
notification: Callback<WebSocketStatus>,
37-
#[cfg(feature = "web_sys")]
3837
#[allow(dead_code)]
3938
listeners: [EventListener; 4],
4039
}
4140

42-
#[cfg(feature = "web_sys")]
4341
impl WebSocketTask {
4442
fn new(
4543
ws: WebSocket,
@@ -159,15 +157,11 @@ impl WebSocketService {
159157
EventListener::new(&ws, "close", listener_close),
160158
EventListener::new(&ws, "error", listener_error),
161159
];
162-
Ok(ConnectCommon(
163-
ws,
164-
#[cfg(feature = "web_sys")]
165-
listeners,
166-
))
160+
Ok(ConnectCommon(ws, listeners))
167161
}
168162
}
169163

170-
struct ConnectCommon(WebSocket, #[cfg(feature = "web_sys")] [EventListener; 3]);
164+
struct ConnectCommon(WebSocket, [EventListener; 3]);
171165

172166
fn process_binary<OUT: 'static>(event: &MessageEvent, callback: &Callback<OUT>)
173167
where
@@ -308,7 +302,6 @@ mod tests {
308302
}
309303

310304
#[test]
311-
#[cfg(feature = "web_sys")]
312305
async fn test_invalid_url_error() {
313306
let url = "syntactically-invalid";
314307
let cb_future = CallbackFuture::<Json<Result<Message, anyhow::Error>>>::default();

packages/yew/src/utils.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ pub fn host() -> Result<String, Error> {
3535
pub fn origin() -> Result<String, Error> {
3636
let location = window().location();
3737

38-
#[cfg(feature = "web_sys")]
3938
let origin = location.origin().map_err(|e| {
4039
anyhow!(e
4140
.as_string()

packages/yew/src/virtual_dom/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ pub(crate) trait VDiff {
353353
) -> NodeRef;
354354
}
355355

356-
#[cfg(feature = "web_sys")]
357356
fn insert_node(node: &Node, parent: &Element, next_sibling: Option<Node>) {
358357
match next_sibling {
359358
Some(next_sibling) => parent
@@ -510,7 +509,7 @@ mod layout_tests {
510509
}
511510
}
512511

513-
#[cfg(all(test, feature = "web_sys", feature = "wasm_bench"))]
512+
#[cfg(all(test, feature = "wasm_bench"))]
514513
mod benchmarks {
515514
use super::{Attributes, PositionalAttr};
516515
use std::borrow::Cow;

packages/yew/src/virtual_dom/vcomp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ mod tests {
554554
}
555555
}
556556

557-
#[cfg(all(test, feature = "web_sys"))]
557+
#[cfg(test)]
558558
mod layout_tests {
559559
extern crate self as yew;
560560

0 commit comments

Comments
 (0)