Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove web_sys re-export #2084

Merged
merged 2 commits into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions examples/boids/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ rand = "0.8"
serde = { version = "1.0", features = ["derive"] }
yew = { path = "../../packages/yew" }
gloo = "0.3"

[dependencies.web-sys]
version = "0.3"
features = [
"HtmlInputElement",
]
6 changes: 2 additions & 4 deletions examples/boids/src/slider.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use std::cell::Cell;
use yew::{
html, web_sys::HtmlInputElement, Callback, Component, Context, Html, InputEvent, Properties,
TargetCast,
};
use web_sys::HtmlInputElement;
use yew::{events::InputEvent, html, Callback, Component, Context, Html, Properties, TargetCast};

thread_local! {
static SLIDER_ID: Cell<usize> = Cell::default();
Expand Down
6 changes: 6 additions & 0 deletions examples/crm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ serde_derive = "1"
yew = { path = "../../packages/yew" }
gloo = "0.3"

[dependencies.web-sys]
version = "0.3"
features = [
"HtmlInputElement",
"HtmlTextAreaElement",
]
6 changes: 4 additions & 2 deletions examples/crm/src/add_client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use crate::Client;
use yew::web_sys::{Event, HtmlInputElement, HtmlTextAreaElement};
use yew::{classes, html, Callback, Component, Context, Html, Properties, TargetCast};
use web_sys::{HtmlInputElement, HtmlTextAreaElement};
use yew::{
classes, events::Event, html, Callback, Component, Context, Html, Properties, TargetCast,
};

#[derive(Debug)]
pub enum Msg {
Expand Down
6 changes: 6 additions & 0 deletions examples/js_callback/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ license = "MIT OR Apache-2.0"
[dependencies]
wasm-bindgen = "0.2"
yew = { path = "../../packages/yew" }

[dependencies.web-sys]
version = "0.3"
features = [
"HtmlTextAreaElement",
]
3 changes: 2 additions & 1 deletion examples/js_callback/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use wasm_bindgen::prelude::*;
use yew::{prelude::*, web_sys::HtmlTextAreaElement};
use web_sys::HtmlTextAreaElement;
use yew::prelude::*;

mod bindings;

Expand Down
7 changes: 7 additions & 0 deletions examples/keyed_list/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@ log = "0.4"
rand = "0.8"
wasm-logger = "0.2"
yew = { path = "../../packages/yew" }

[dependencies.web-sys]
version = "0.3"
features = [
"HtmlElement",
"HtmlInputElement",
]
2 changes: 1 addition & 1 deletion examples/keyed_list/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use instant::Instant;
use person::PersonType;
use web_sys::{HtmlElement, HtmlInputElement};
use yew::html::Scope;
use yew::prelude::*;
use yew::web_sys::{HtmlElement, HtmlInputElement};

mod person;
mod random;
Expand Down
6 changes: 6 additions & 0 deletions examples/store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@ yew = { path = "../../packages/yew" }
yew-agent = { path = "../../packages/yew-agent" }
wasm-bindgen = "0.2"
gloo-console = "0.1"

[dependencies.web-sys]
version = "0.3"
features = [
"HtmlInputElement",
]
2 changes: 1 addition & 1 deletion examples/store/src/text_input.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use web_sys::HtmlInputElement;
use yew::prelude::*;
use yew::web_sys::HtmlInputElement;

pub enum Msg {
Submit(String),
Expand Down
6 changes: 6 additions & 0 deletions examples/todomvc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ serde = "1"
serde_derive = "1"
yew = { path = "../../packages/yew" }
gloo = "0.3"

[dependencies.web-sys]
version = "0.3"
features = [
"HtmlInputElement",
]
12 changes: 8 additions & 4 deletions examples/todomvc/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
use gloo::storage::{LocalStorage, Storage};
use state::{Entry, Filter, State};
use strum::IntoEnumIterator;
use yew::html::Scope;
use yew::web_sys::HtmlInputElement as InputElement;
use yew::{classes, html, Component, Context, FocusEvent, Html, NodeRef, TargetCast};
use yew::{events::KeyboardEvent, Classes};
use web_sys::HtmlInputElement as InputElement;
use yew::{
classes,
events::{FocusEvent, KeyboardEvent},
html,
html::Scope,
Classes, Component, Context, Html, NodeRef, TargetCast,
};

mod state;

Expand Down
9 changes: 9 additions & 0 deletions packages/website-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,14 @@ weblog = "0.3.0"
yew = { path = "../../packages/yew/" }
yew-router = { path = "../../packages/yew-router/" }

[dev-dependencies.web-sys]
version = "0.3"
features = [
"Element",
"EventTarget",
"HtmlElement",
"HtmlInputElement",
]

[build-dependencies]
glob = "0.3"
9 changes: 5 additions & 4 deletions packages/yew-macro/tests/html_macro/html-element-pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ pub struct u8;
pub struct usize;

fn compile_pass() {
let onclick = <::yew::Callback<::yew::MouseEvent> as ::std::convert::From<_>>::from(
|_: ::yew::MouseEvent| (),
let onclick = <::yew::Callback<::yew::events::MouseEvent> as ::std::convert::From<_>>::from(
|_: ::yew::events::MouseEvent| (),
);
let parent_ref = <::yew::NodeRef as ::std::default::Default>::default();

let dyn_tag = || <::std::string::String as ::std::convert::From<&::std::primitive::str>>::from("test");
let dyn_tag =
|| <::std::string::String as ::std::convert::From<&::std::primitive::str>>::from("test");
let mut extra_tags_iter = ::std::iter::IntoIterator::into_iter(::std::vec!["a", "b"]);

let cow_none: ::std::option::Option<::std::borrow::Cow<'static, ::std::primitive::str>> =
Expand Down Expand Up @@ -103,7 +104,7 @@ fn compile_pass() {
<track kind={::std::option::Option::Some(::std::borrow::Cow::Borrowed("subtitles"))} src={::std::clone::Clone::clone(&cow_none)} />
<track kind={::std::option::Option::Some(::std::borrow::Cow::Borrowed("5"))} mixed="works" />
<input value={::std::option::Option::Some(::std::borrow::Cow::Borrowed("value"))}
onblur={::std::option::Option::Some(<::yew::Callback<::yew::FocusEvent> as ::std::convert::From<_>>::from(|_| ()))}
onblur={::std::option::Option::Some(<::yew::Callback<::yew::events::FocusEvent> as ::std::convert::From<_>>::from(|_| ()))}
/>
</div>
};
Expand Down
6 changes: 0 additions & 6 deletions packages/yew/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,16 @@ scoped-tls-hkt = "0.1"
version = "0.3"
features = [
"AnimationEvent",
"console",
"Document",
"DragEvent",
"Element",
"ErrorEvent",
"Event",
"EventInit",
"EventTarget",
"File",
"FileList",
"FileReader",
"FocusEvent",
"HtmlElement",
"HtmlButtonElement",
"HtmlInputElement",
"HtmlSelectElement",
"HtmlTextAreaElement",
"InputEvent",
"InputEventInit",
Expand Down
3 changes: 2 additions & 1 deletion packages/yew/src/functional/hooks/use_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ use std::{cell::RefCell, rc::Rc};
///
/// # Example
/// ```rust
/// # use yew::{prelude::*, web_sys::{Event, HtmlInputElement}};
/// # use yew::prelude::*;
/// # use web_sys::HtmlInputElement;
/// # use std::rc::Rc;
/// # use std::cell::RefCell;
/// # use std::ops::{Deref, DerefMut};
Expand Down
6 changes: 4 additions & 2 deletions packages/yew/src/html/listener/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ where
/// # Example
///
/// ```
/// use yew::{prelude::*, web_sys::{Event, HtmlTextAreaElement}};
/// use yew::prelude::*;
/// use web_sys::HtmlTextAreaElement;
/// # enum Msg {
/// # Value(String),
/// # }
Expand Down Expand Up @@ -93,7 +94,8 @@ where
/// # Example
///
/// ```
/// use yew::{prelude::*, web_sys::{Event, HtmlInputElement}};
/// use yew::prelude::*;
/// use web_sys::HtmlInputElement;
/// # enum Msg {
/// # Value(String),
/// # }
Expand Down
2 changes: 0 additions & 2 deletions packages/yew/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,6 @@ pub mod scheduler;
pub mod utils;
pub mod virtual_dom;

pub use web_sys;

/// The module that contains all events available in the framework.
pub mod events {
pub use crate::html::TargetCast;
Expand Down
4 changes: 2 additions & 2 deletions website/docs/concepts/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ is also a parameter called `first_render` which can be used to determine whether
being called on the first render, or instead a subsequent one.

```rust
use web_sys::HtmlInputElement;
use yew::{
Component, Context, html, Html, NodeRef,
web_sys::HtmlInputElement
Component, Context, html, Html, NodeRef,
};

pub struct MyComponent {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/concepts/components/callbacks.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ The function passed to `callback` must always take a parameter. For example, the
If you need a callback that might not need to cause an update, use `batch_callback`.

```rust
use yew::{html, Component, Context, Html, KeyboardEvent};
use yew::{events::KeyboardEvent, html, Component, Context, Html};

enum Msg {
Submit,
Expand Down
3 changes: 2 additions & 1 deletion website/docs/concepts/components/refs.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ a canvas element after it has been rendered from `view`.
The syntax is:

```rust
use yew::{html, web_sys::Element, Component, Context, Html, NodeRef};
use web_sys::Element;
use yew::{html, Component, Context, Html, NodeRef};

struct Comp {
node_ref: NodeRef,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ If you need the component to be re-rendered on state change, consider using [`us
### Example

```rust
use web_sys::HtmlInputElement;
use yew::{
events::Event,
function_component, html, use_ref, use_state,
web_sys::{Event, HtmlInputElement},
Callback, TargetCast,
};

Expand Down
4 changes: 2 additions & 2 deletions website/docs/concepts/html/elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Using `web-sys`, you can create DOM elements and convert them into a `Node` - wh
used as a `Html` value using `VRef`:

```rust
use web_sys::{Element, Node};
use yew::{
Component, Context, html, Html, utils::document,
web_sys::{Element, Node}
Component, Context, html, Html, utils::document,
};

struct Comp;
Expand Down
21 changes: 14 additions & 7 deletions website/docs/concepts/html/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,10 @@ wasm-bindgen = "0.2"
```rust
//highlight-next-line
use wasm_bindgen::JsCast;
use web_sys::{EventTarget, HtmlInputElement};
use yew::{
events::Event,
html,
web_sys::{Event, EventTarget, HtmlInputElement},
Component, Context, Html,
};

Expand Down Expand Up @@ -295,9 +296,10 @@ from events.
but it works in a very similar way to `JsCast`.

```rust
use web_sys::HtmlInputElement;
use yew::{
events::Event,
html,
web_sys::{Event, HtmlInputElement},
// Need to import TargetCast
//highlight-next-line
Component, Context, Html, TargetCast,
Expand Down Expand Up @@ -366,8 +368,10 @@ does the cast on the target of the event. `TargetCast::target_unchecked_into` is
[`NodeRef`](../components/refs.md) can be used instead of querying the event given to a `Callback`.

```rust
//highlight-next-line
use yew::{html, web_sys::HtmlInputElement, Component, Context, Html, NodeRef};
//highlight-start
use web_sys::HtmlInputElement;
use yew::{html, Component, Context, Html, NodeRef};
//highlight-end

pub struct Comp {
//highlight-next-line
Expand Down Expand Up @@ -425,7 +429,8 @@ You might also see by using `NodeRef` we don't have to send the `String` back in
`Msg::InputValue` as we always have `my_input` in the component state - so we could do the following:

```rust
use yew::{html, web_sys::HtmlInputElement, Component, Context, Html, NodeRef};
use web_sys::HtmlInputElement;
use yew::{html, Component, Context, Html, NodeRef};

pub struct Comp {
my_input: NodeRef,
Expand Down Expand Up @@ -512,9 +517,10 @@ yourself ([there is a more concise way thanks to `gloo`](#using-gloo-concise)).

```rust
use wasm_bindgen::{prelude::Closure, JsCast};
use web_sys::HtmlElement;
use yew::{
events::Event,
html,
web_sys::{Event, HtmlElement},
Component, Context, Html, NodeRef,
};

Expand Down Expand Up @@ -617,9 +623,10 @@ gloo-events = "0.1"
```

```rust
use web_sys::HtmlElement;
use yew::{
events::Event,
html,
web_sys::{Event, HtmlElement},
Component, Context, Html, NodeRef,
};

Expand Down