320 Commits

Author SHA1 Message Date
dependabot[bot]
7d873b264c
Update gloo-console requirement from 0.1 to 0.2 (#2122)
Updates the requirements on [gloo-console](https://github.com/rustwasm/gloo) to permit the latest version.
- [Release notes](https://github.com/rustwasm/gloo/releases)
- [Commits](https://github.com/rustwasm/gloo/commits/0.2.0)

---
updated-dependencies:
- dependency-name: gloo-console
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-11-11 16:10:31 +01:00
Muhammad Hamza
dd2db93996
Use functions from gloo_utils instead of re-implementing them (#2124)
* Use functions from `gloo_utils` instead of re-implementing them

* Remove `anyhow` dependency

* fix errors

* review + post merge fixes
2021-11-11 16:45:08 +02:00
Kaede Hoshikawa
706fb48f6e
Reliable use_reducer dispatch and use_state setter (#2126)
* Add Redirect Comp.

* Fix router behaviour.

* Fix output.

* Fix pr-flow.

* Remove Redirect.

* Readd 77b46bf.

* Reliable dispatch for use_reducer.

* Detachable Dispatcher and Setter.

* Update docs wording.

* Update website/docs/concepts/function-components/pre-defined-hooks.md

Co-authored-by: Simon <simon@siku2.io>

* Update website/docs/concepts/function-components/pre-defined-hooks.md

Co-authored-by: Simon <simon@siku2.io>

* Update website/docs/concepts/function-components/pre-defined-hooks.md

Co-authored-by: Simon <simon@siku2.io>

Co-authored-by: Simon <simon@siku2.io>
2021-11-11 12:33:33 +01:00
Kaede Hoshikawa
f43760e3ca
Update Yew Router as per #2113 (#2118)
* Add Redirect Comp.

* Fix router behaviour.

* Fix output.

* Fix pr-flow.

* Remove Redirect.

* Readd 77b46bf.

* Router Context, History and Location.

* Finish Porting.

* Add Switch, Fix example.

* Add state.

* Fix pr-flow.

* Fix pr-flow.

* Fix unstable feature for 1.49.

* Add documentation.

* Error Types & Simplify Implementation.

* Add some tests.

* Update documentation.

* Fix route outside of a Switch.
2021-11-11 13:08:42 +02:00
Muhammad Hamza
2f47b09da4
Add custom type for attribute values (#1994)
* Add custom type for attribute values

* fix tests/example

* Remove `PartialEq<String>` and it's usage

* `ReferenceCounted` -> `Rc`

* fucking fake

* please CI, just turn green
2021-11-08 18:11:22 +01:00
Vinícius Miguel
8fd6100874
Remove trailing semicolon in macro used in expression position (#2127) 2021-11-02 14:22:39 +01:00
mc1098
98821c4018
Fix default passive option (#2111) 2021-10-16 22:16:13 +02:00
Kaede Hoshikawa
35e1ba60aa
Fix Some Router Behaviour (#2107)
* Add Redirect Comp.

* Fix router behaviour.

* Fix output.

* Fix pr-flow.

* Remove Redirect.

* Readd 77b46bf.
2021-10-16 20:02:08 +01:00
Julius Lungys
f2a0d617ce
Add set_if_neq for UseStateHandle (#2109)
* add set_neq for UseStateHandle

* add docs

* update based on PR comments 1
2021-10-16 00:25:16 +01:00
mc1098
77b46bfa40
Fix trybuild (#2103) 2021-10-08 01:57:24 +01:00
mc1098
dbd8545a03
Add documentation for wasm-bindgen (#2082)
* Add documentation for wasm-bindgen

Adds a wasm-bindgen section to docs and gives a high level
description of it's crates and how they are used with Yew.

* Fix typos and formatting

* Expand JS example section

* fix re-export web_sys through yew info

* Add HtmlSelectElement feature

* Fix identing

* Fix code example comment
2021-10-02 19:59:50 +02:00
mc1098
ae2ebc9776
Add safe first_node fn (#2094)
`first_node` function can fail and in some situations, when the VNode
has not been mounted yet, so this adds a safe version that returns an
`Option<Node>` and refactors the previous version to use the "unchecked"
prefix as it can and should panic if the first node cannot be found.
2021-10-02 11:20:18 +02:00
Muhammad Hamza
78bb994ba2
impl PartialEq for UseStateHandle and UseReducerHandle (#2092) 2021-09-29 11:26:07 +01:00
mc1098
e503c9acda
Remove web_sys re-export (#2084)
* Remove `web_sys` re-export

Removes re-exporting the `web_sys` dependency from the yew crate and
removes some `web_sys` features that were only enabled for re-exporting.

* re-export events through yew::events
2021-09-27 02:07:38 +02:00
Andrew Straw
0e4be56a18
yew-agent: add missing web-sys features (#2085) 2021-09-26 08:33:00 +01:00
Xavientois
97498cdfcd
Use into_prop_value to convert str prop to Option<String> (#2080) 2021-09-24 09:00:39 +02:00
Janis Petersons
a442ce5df5
Component lifecycle scheduler optimizations (#2065)
* yew: partial render deduplication implementation

* yew/scheduler: batching and comment fixes

* yew/scheduler: clippy fixes

* yew/vcomp: add lifecycle debug logging

* ci: add release clippy and cargo check passes

* ci: fix release check

* ci: remove duplicate check calls
2021-09-22 17:57:14 +02:00
mc1098
4ca68e07ca
Fix unmaintained anymap dependency (#2071)
This changes the dependency on anymap which is unmaintained and has a
soundness bug to an updated fork `anymap2` where the soundness bug has
been fixed.
2021-09-21 21:10:14 +02:00
mc1098
adb3fcfce1
Update dependencies (#2064)
General review of dependencies, removing ones that are not used and
bumping up minor versions to avoid breakage.

Consistent use of caret so that we use the most recent minor/patch
version of a dependency when building Yew crates.
2021-09-19 11:14:08 +02:00
mc1098
99a91345cd
Fix event handler during capture phase (#2062)
* Add failing test for non bubbling events

Adds a failing test to identify the issue raised in #2061

* Fix handling events in capture phase

The global mutltiplex registers an event listeners on the body element
and then we do the event bubbling manually in Yew, however, because we
were still registering event listeners to run on the bubbling phase
events that do not bubble (like blur) never reach the body element.
2021-09-18 11:10:24 +01:00
mc1098
2ede4ad81c
Remove unused ssri dependency (#2063)
It got updated recently but this dependency is never used.
2021-09-18 11:09:05 +01:00
Kat Marchán
c2ae6b2acf
deps: bump to ssri 7.0 for more permissive license (#2059)
Fixes: #2057
2021-09-16 18:12:17 +01:00
mc1098
c4dee74e4a
Add support for missing boolean attributes (#2051) 2021-09-12 20:03:03 +01:00
mc1098
83e565a1e6
Add check for hook state (#2042)
This checks if the hook state has been set and if not provides a
specific error message for why the hook state has not been set.
2021-09-09 22:26:31 +02:00
mc1098
4c6da9aab3
Add fully qualified primitives in proc macro (#2037)
* Add primitive shadowing in macro tests

* Fix primitive types to be fully qualified
2021-09-07 09:40:09 +02:00
mc1098
1ab7779a8f
Remove 'static lifetime from hook init function (#2039)
Hooks with initialization functions had a 'static lifetime requirement
on the signature, however, any closure given only needs to have a
lifetime that lives as long as the hook call.
2021-09-07 09:37:46 +02:00
mc1098
282eb1943f
Expand event documentation for next (#2036)
* Expand event documentation

* Add import for code block

* Fix formatting
2021-09-06 21:02:58 +01:00
Xavientois
eeddcb95be
Add "struct update" syntax to pass props to component (..props instead of with props) (#2024)
* Reword to use double-dot syntax instead of "with"

* Implement double-dot syntax for props in components

* Update documentation with new syntax

* Update forgotten doc

* Add descriptive comments

* Check props and base expression

* Make compatible with 1.49.0 by removing then

* Fix website tests

* Update error output

* Implicitly convert string literals to String if they are listed as props

* Remove unused keyword

* Rename function for checking if string literal

* Fix weird formatting

* Update code based on review

* Update website/docs/concepts/html/components.md

Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>

* Base expression span includes dot2 now

* Improve specificity of error message

* Chain together error messages

* Add an example failure case to illustrate combined error message

* Update based on review comments

* Fix missing clones

Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>
2021-09-06 06:41:51 +01:00
mc1098
58753d9607
Add no_implicit_prelude to proc macro tests (#2033)
* Add no_implicit_prelude to derive_props test

* Add no_implicit_prelude to html_macro tests

* Fix function_component macro tests

function_component macro tests weren't being run by try build due to
change in dir name. Imports corrected now that function_component is now
in yew.

Adds no_implicit_prelude to *-pass tests

* Add no_implicit_prelude to props_macro tests

* fix typo in comment
2021-09-05 23:33:30 +01:00
mc1098
e1b85b2b80
Move tutorial to next docs (#2032)
Tutorial should be in the docs so that it can be matched to the version
yew that a user is trying to be informed on.

The tutorial now comes under the scope of website testing so had to
tweak the tutorial to pass the tests.
2021-09-04 17:38:17 +02:00
mc1098
df9d7ab160
Fix VTag reuse to reset ancestor NodeRef (#2030)
* Add test for VTag reuse not resetting NodeRef

Add a failing test to identify the issue #2029

* Fix NodeRef reset when reusing VTag element
2021-09-03 16:30:57 +01:00
mc1098
c307f07fb8
Fix IntoEventCallback over IntoPropValue (#2025)
PR #1542 didn't merge in the changes from #1989 correctly, this is fixed
in this commit.
2021-08-31 12:10:28 +01:00
rjmac
7a55441dae
Add "replace route" call as a companion to "push route" (#2023)
* Add "replace route" call as a companion to "push route"

* Fix test

* Make the yew-router tests run

Co-authored-by: Robert Macomber <robertm@mox>
2021-08-29 23:57:22 +02:00
mc1098
0e52b88742
Update gloo dependencies in yew and examples (#2021)
Updates to using the latest stable gloo, in some cases removing
dependencies on `master` branch.

Removes `weblog` in favour of `gloo_console`, where applicable.
2021-08-29 02:13:06 +01:00
Janis Petersons
68d2fdbc59
Dev/listener multiplexer (#1542)
* yew: partial event listener multiplexer

web_sys implementaion compiles but the std_web implementation is unfinished. Keeping this only to commit curretn progress before reverting std_web.

* yew: partial event listener multiplexer

Feature parity with master, except for bubbling.

* yew/listener: fix and test synchronous listeners

* yew/listener: add placeholder comments

* yew/listener: passive listener test

* yew: extend and fix APIs and docs

* yew/listener: event bubbling

* clippy: ignore warning

* Update yew/src/callback.rs

Co-authored-by: Simon <simon@siku2.io>

* Update yew/src/html/listener/listener_stdweb.rs

Co-authored-by: Simon <simon@siku2.io>

* Apply suggestions from code review

Co-authored-by: Simon <simon@siku2.io>

* Apply suggestions from code review

Co-authored-by: Simon <simon@siku2.io>

* yew/listner: remove redundant function

* yew/listner: restore delibarate formatting

* yew/callback: make Flags a newtype

* yew/listener: use utility function

* yew/listener: deferred listeners

* yew/listner: input and change tests

* yew/listener: optimize listener registration

* yew/listener: remove benchmark placeholders

Seems easybench-wasm does not support specifying a module path.

* yew/callback: revert CallbackOnce -> Once

* yew: convert listener_tests to a build flag

* Apply suggestions from code review

Co-authored-by: Simon <simon@siku2.io>

* yew: fix doc comments

* yew: simplify iteration

* yew/remove unneeded default passive listeners

* yew/listeners: DRY some more

* yew/listener: fix clippy warnings

* yew/listeners: remove legacy comment

* yew/listeners: document stopping propagation

* yew/listeners: update tests

* ci: see how test run on stable

* ci: let's find the new MSRV

* ci: try to run integration tests only on stable

* yew/test: clean up residual dirty state

* yew/listeners: minor doc string and inline fixes

* yew/listener: document reasonning for function

Co-authored-by: Simon <simon@siku2.io>
2021-08-28 18:56:03 +02:00
mc1098
ed2e1ea00e
Add testing for website code blocks (#2014)
* Add doc-test to test website code snippets

Heavily inspired by tokio-rs/website repo.

* Fix code snippets to pass doc tests

Some code snippets are explicitly ignored and some are not run
to avoid having to include dependencies for one liners.

* Add website code snippet tests to CI

* Fix CI

* Remove doc-test from workspace

* Exclude doc-test from workspace

* Refactor code snippets and tests

Code snippets can import types from doc_test crate i.e.:
```rust
use doc_test::agents::EventBus;
```
This allows for moving some boilerplate away from the example and still
checks that the code compiles correctly.

Also some slight changes to some of the examples and the information
about `ComponentLink` which is deprecated.

* Move doc-test to packages

* Rename doc-test crate to website-test

The new name makes it more clear the purpose of this crate.

* fix ci
2021-08-28 13:17:28 +02:00
mc1098
4e974dad92
Remove ShouldRender type alias (#2011)
Remove `ShouldRender` type alias for bool. In the Component trait an
extra comment has been added to explain what the returned bool
represents.
2021-08-25 17:52:09 +02:00
mc1098
5b34ce9e9d
Remove underscore prefix on fn parameters (#2010)
The Component trait fn definitions don't contain the underscore prefix
as this is not IDE friendly.
2021-08-25 15:34:16 +01:00
Muhammad Hamza
f50c8c3cba
Components v2 (2) (#1961)
* Start rewrite

* Rc > cloning props

* fmt + rm useless file

* move props inside `Context`

* router compiles

* fix boids example

* fix counter example

* fix crm example

* fix dyn_create_destroy_apps example

* fix file_upload example

* fix futures example

* fix game_of_life example

* fix inner_html example

* fix js_callback example

* fix mount_point example

* fix keyed_list example

* fix web_gl example

* fix two_apps example

* fix todomvc example

* fix timer example

* fix store example

* fix nested_list example

* fix node_refs example

* fix pub_sub example

* fix multi_thread example

* don't call `changed` if props weren't changed

* formatting

* fix doc tests, remove neq_assign

* update router example, fix neq_assign compile errors

* fix macro/rest of doc tests

* start updating documentation

* `Component`'s documentation

* Apply suggestions from code review

Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>

* Apply suggestions from code review (part 2)

* Apply suggestions from code review (part 3)

* fix context

* clippy

* post merge fixes

Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>
2021-08-25 13:11:39 +01:00
mc1098
f574c2fce3
Fix onsubmit handler to take Event (#2009)
onsubmit takes a `SubmitEvent` which is not available in web_sys.
`SubmitEvent` does not inherit from `FocusEvent` so
`FocusEvent::related_target` panics too!

As with onformdata onsubmit will use `Event` to remain safe and requires
users to define their own type or use Reflect api.

Trybuild change because of the new comment.
2021-08-22 00:16:28 +02:00
Karlitos
855de12313
Fix rust-analyzer #[derive(Properties)] warnings (#2007)
Fix #2006
2021-08-18 19:57:15 +02:00
mc1098
c6099cf875
Remove InputData & ChangeData (#2000) 2021-08-16 18:02:14 +02:00
Muhammad Hamza
c6458f124a
Allow taking Fn(EVENT) for callbacks too (#1989)
* Allow taking `Fn(EVENT)` for callbacks too

* fix bad test

* fmt

* add tests
2021-08-09 17:53:49 +02:00
mc1098
5ea6aec804
Fix multiple field enum tokens (#1988)
A small change so that enums with multiple fields are comma seperated.
2021-08-04 20:44:21 +02:00
Maciej Hirsz
47550292d5
Support const generics in #[derive(Properties)] (#1978)
* Support const generics in #[derive(Properties)]

* Test and tweak comment
2021-07-31 23:09:57 +02:00
Xavientois
c1226a2813
Add shorthand syntax for props (#1970)
* Allow shortened prop syntax

* Use new syntax where appropriate

* Apply suggestions from code review

Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>

* Add tests to hit newly added error messages

* Fix clippy lints

* Re-trigger CI

* Revert error text

Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>
2021-07-31 23:01:02 +02:00
bakape
8fbb1a24cc
Static attribute lists (#1962)
* yew-macro: optimize VTag construction in html! macro

* yew/vtag: decrease VTag memory footpting and construction args

* yew,yew-macro: optimize VTag contruction, memory footprint and diffing

* yew/vlist: revert to VTag boxing

* yew-macro: add clippy allow for nightly rust

* yew-macro:  fix allow namespace

* *: bump MSRV to 1.49.0

* yew/attributes: static attribute keys and values

* yew/attributes: use boxed slices and inline dynamic class construction

* Update packages/yew/src/virtual_dom/vtag.rs

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>

* yew/vnode: revert mismerge

* yew/classes: add safety explanation comment

* Update packages/yew/src/utils/mod.rs

Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>
Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>
2021-07-31 23:00:10 +02:00
Xavientois
c9deba05f1
Fix clippy lints from 1.54.0 (#1976)
* Fix clippy lints from 1.54.0

* Format fixed code
2021-07-30 17:21:45 +02:00
Xavientois
26d42ba2a9
Remove unused punct field from props (#1969) 2021-07-25 14:52:04 +02:00
Francis Murillo
1721669d71
Drop Private worker handler when bridge is dropped (#1944) 2021-07-19 01:15:16 +02:00