433 Commits

Author SHA1 Message Date
WorldSEnder
ae7a8be008
use base url for href of links (#2177) 2021-11-22 20:09:41 +05:00
Matt
4c3d6934a8
Remove extra braces in html_nested macro (#2169)
* removed unused braces from html_nested marco

* allow specifying test name

* also fix for html! macro

* also fix for html! macro

* remove misplaced #[allow(unused_braces)]
2021-11-21 17:09:30 +02:00
Teymour Aldridge
7e2542cbf8
Add basic lints to the HTML macro. (#1748)
* Add basic lints to the HTML macro.

* f

* Fix the examples.

* Fix nightly warning message tests.

* apply code review suggestions

* update error message

* rebase onto master

* remove unused props

* remove console log

* remove js void

* fix according to PR comments

Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>
2021-11-21 19:54:49 +05:00
mc1098
071f1b28df
Refactor use ref hooks (#2093)
* Refactor use ref hooks

`use_ref` has been renamed to `use_mut_ref` and `use_ref` has become a
similar hook for immutable reference.

This is different from React but I think lines up nicely with Rust as a
reference is immutable unless specified to be a mut ref.

* fix CI

Co-authored-by: Hamza <muhammadhamza1311@gmail.com>
2021-11-21 16:20:19 +02:00
Marcel
068a20abba
AttrValue's PartialEq takes the enum variant into account (#2162)
* Attempt to fix recursion on display

* Include into_string() for AttrValue

* PartialEq takes the enum variant into account #2161

Co-authored-by: mibes <mibes@avaya.com>
2021-11-20 15:40:49 +02:00
Andrew Straw
916dc2e907
allow web worker resource to be relative (#2086)
* allow web worker resource to be relative

fixes #2056

* make backwards compatible with rust < 1.52

* fix clippy warning

* Apply suggestions from code review

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

* do not reimplement stdlib function

* fixup previous

* improve docstring

Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>
2021-11-20 15:39:35 +02:00
Marcel
2b1059b4b5
Implements into_string() for AttrValue (#2153)
* Attempt to fix recursion on display

* Include into_string() for AttrValue

Co-authored-by: mibes <mibes@avaya.com>
2021-11-19 20:34:07 +05:00
WorldSEnder
aa9b9b266c
Implementation of portals (#2147)
* initial poc implementation of portals

* add new_before

* add portals example

* add shadow dom example

* add english website documentation
2021-11-16 16:48:04 +01:00
Shihpin Tseng
a5c343dd62
add Clone implementation for use_bridge (#2150) 2021-11-16 09:06:32 +00:00
Marcel
ee54bbdff2
Attempt to fix recursion on display (#2149)
Co-authored-by: mibes <mibes@avaya.com>
2021-11-16 09:03:40 +00:00
Kaede Hoshikawa
fb9c398048
use_bridge hook for agents (#2125)
* Add Redirect Comp.

* Fix router behaviour.

* Fix output.

* Fix pr-flow.

* Remove Redirect.

* Readd 77b46bf.

* Add use_bridge hook.

* Add documentation.
2021-11-12 09:04:03 +01:00
Jonas Platte
39886d4675
Allow Classes properties to be created from string literals (#2141)
* Allow Classes properties to be created from string literals

* Update test output
2021-11-11 22:02:05 +02:00
dependabot[bot]
8a43880586
Update gloo requirement from 0.3 to 0.4 (#2123)
Updates the requirements on [gloo](https://github.com/rustwasm/gloo) to permit the latest version.
- [Release notes](https://github.com/rustwasm/gloo/releases)
- [Commits](https://github.com/rustwasm/gloo/compare/0.3.0...0.4.0)

---
updated-dependencies:
- dependency-name: gloo
  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:57 +01:00
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