329 Commits

Author SHA1 Message Date
Kai Salmon
1542e2b181
Only handle "normal" clicks on <Link>s (#3056)
* Fixing https://github.com/yewstack/yew/issues/2911

Prevents Link onclick behaviour from executing if the Ctrl key (for
Windows and Linux) or Meta Key (For Mac) is pressed.

This technically introduces a bug that means that links will reload the
page on windows machines when the windows key is held down. However,
this error is also in React Router, so I think we can get away with it.

See:
11156ac7f3/packages/react-router-dom/dom.ts (L29)

* Router Links now use default browser behaviour for alt and shift keys.

This change is inspired by 11156ac7f3/packages/react-router-dom/dom.ts (L29)

This allows uses to shift click links to save whatever the link points
at, and alt click on links to open them in new windows
2022-12-22 21:38:26 +01:00
WorldSEnder
aebd225963
Reentrant event listeners (#3037)
* add test case for reentrent event listeners
* use Fn to allow reentrent event listeners
2022-12-21 01:57:55 +00:00
Cecile Tonglet
d14fcd2e2d
Add impl IntoIterator on &Classes (#3038) 2022-12-14 02:07:16 +05:00
WorldSEnder
57f45e2c81
Assert there are no circular references (#3025)
* assert there are no circular references

the check is costly in release builds and should always fail
note that the current PartialEq impl is *not* symmetric!
should be fixed as well, with an improved design

* remove internal test for cyclic node refs

wasm_bindgen does not yet support #[should_panic]
see also https://github.com/rustwasm/wasm-bindgen/issues/2286
2022-12-10 16:36:59 +01:00
WorldSEnder
d7f988055f
Fix top-level reconciliation in portals (#3020) 2022-12-10 14:42:53 +01:00
Cecile Tonglet
772763c2e2
Make Classes cheap to clone (#3021)
* Use AttrValue instead of Cow in Classes

* Wrap indexset into Rc

* Impl ImplicitClone for Classes

* clippy

* Trigger CI

* Update macro stderr

* Copy optimization made for String to AttrValue

* Update macro stderr again
2022-12-10 18:02:36 +05:00
WorldSEnder
9e980a36b4
Fix clippy::let_unit_value lint in propless components (#2970) 2022-12-09 00:10:22 +05:00
IchHabeKeineNamen
77b0d40455
fix: dead links (#3013) 2022-12-06 06:31:35 +00:00
GitHub Action
17f125c9ec (cargo-release) version {{crate_name}}-v{{version}} 2022-11-28 19:14:03 +00:00
Julius Lungys
2fcb2a32bd
Add yew-agent repository, homepage, documentation (#2985) 2022-11-28 20:01:39 +02:00
GitHub Action
e32d8bd8bb (cargo-release) version {{crate_name}}-v{{version}} 2022-11-25 18:28:11 +05:00
GitHub Action
05d2ec4434 (cargo-release) version {{crate_name}}-v{{version}} 2022-11-25 18:28:11 +05:00
GitHub Action
09a7f2f457 (cargo-release) version {{crate_name}}-v{{version}} 2022-11-25 18:28:11 +05:00
GitHub Action
1bbe75ec9b (cargo-release) version {{crate_name}}-v{{version}} 2022-11-25 18:28:11 +05:00
Muhammad Hamza
f0209c786f
Prepare for Yew 0.20 (#2973)
* 0.20 Changelog

* Improve changelog generator

* Add blog post

* Add blog post

* Apply suggestions from code review

Co-authored-by: WorldSEnder <WorldSEnder@users.noreply.github.com>
Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>

* update Changelog

* update Cargo.toml

* changelog gen compiles

* website version 0.20

* add migration guides

* prettier

* i18n

Co-authored-by: WorldSEnder <WorldSEnder@users.noreply.github.com>
Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>
2022-11-25 15:19:07 +05:00
Muhammad Hamza
90c7ff105a
Add VNode::from_html_unchecked (#2842)
* Add VNode::html_from_raw

* Add docs for VNode::html_from_raw

* feature lock to available flags

* Actually raw

* Formatting + docs

* Tests

* More tests + docs

* fmt

* clippy

* CI

* No <div> around multi top-level nodes

* Update docs

* Fix braw detach

* Clippy & fmt

* Fix compile errors

* I hope you get attacked by Cow, Clippy

* Address review

* Reduce DOM calls

* improve detach bundle impl

* Add more tests

* Update example

* fmt

* Apply review suggestions

* fmt

* fix ci

* fix braw shift with multiple nodes

* rename function name

* fmt

* this should've been there

* ci be green
2022-11-08 21:24:49 +05:00
WorldSEnder
3b4fa888bc
add ability to update app props (#2951) 2022-11-08 21:22:05 +05:00
Christopher Schramm
b649e9dacd
Avoid clippy::let-underscore-drop (#2952)
The following main.rs replicates the clippy warning:

```
use yew::prelude::*;

struct Props {
    droppable: Vec<()>,
}

fn component(props: &Props) -> Html {
    let props = Props { droppable: Vec::new() };
    html! { <Component ..props /> }
}

fn main() {}
```

If I'm not mistaken this happens when using the `..` on any `Properties` with a field that implements `Drop`.
2022-11-08 21:21:06 +05:00
Muhammad Hamza
ccaa06a2fa
Clippy + update lock files (#2949) 2022-11-05 16:05:08 +01:00
Kaede Hoshikawa
da09755c27
Separate Yew Platform (#2893)
* Remove pinned module.

* Create Yew Platform.

* Remove some additional dependencies.

* Fix clippy.

* Restore wasm-bindgen-futures.

* Fix docs.

* Migrate to prokio.

* Fix docs warnings.

* Fix dependencies.
2022-10-21 06:56:15 +09:00
Kaede Hoshikawa
5f6e094996
Use Ref::filter_map if rustc is later than 1.63 (#2904) 2022-10-19 19:45:27 +09:00
Muhammad Hamza
7ada3447bb
Fix issues with tuples in closing tag (#2886)
* Add test case for #2225

* Fix issues with tuples in closing tag

* Improve diagnostics

* fmt

* better diagnostics
2022-10-08 20:59:08 +05:00
WorldSEnder
bb71b5db61
Fix checked property being reset (#2907)
if the value is uncontrolled, do not touch it. Only if it is explicitly given
2022-10-08 20:50:19 +05:00
Muhammad Hamza
426a1fd81d
Evaluate props in the order they're defined (#2887)
* don't change order of props

* rename `SortedPropList` to `PropList`

* docs + test

* remove dead code

* fmt
2022-10-08 10:40:55 +02:00
wdcocq
32b3150cb3
Fix panic because of unwrapping when resuming suspension (#2902)
* Replace unwrap with if let to prevent panic

* Add resume after unmount test

* Change BaseSuspense methods to associated functions

* Fix rustfmt issues
2022-10-04 05:45:46 +02:00
WorldSEnder
0ecee11a2f
Fix portal shifting on reconciliation too often (#2891)
* fix portal shifting on reconciliation too often

the public vdom api changes to only allow directly
setting a Node as sibling (still optional) instead of a NodeRef.
This was the intention all along, since the NodeRef was
not dynamically tracked, and creating a portal into a subtree
already controlled by yew is not supported anway.

* fix feature soundness

* fix doc tests
2022-09-28 09:32:19 +03:00
Dietmar Maurer
73d9c04782
Context: cleanup - avoid storing a copy of children (#2885)
The new changed() signature allows accessing old_props, so
there is no more need to store an additional copy of children.
2022-09-25 18:42:30 +05:00
Muhammad Hamza
9e0d7966bc
Make Yew lints opt-in (#2882)
* Add compiler flag for Yew lints

* Use --cfg yew_lints in CI

* Remove lints feature

* bless the fail.stderr

* Fix CI
2022-09-25 21:54:24 +09:00
Muhammad Hamza
7e24fb3c58
Clippy fixes (#2881)
* Clippy in root

* Clippy in examples

* didn't mean to commit this file
2022-09-25 21:25:23 +09:00
Nathan West
6751946477
Various improvements to Classes, oriented around reducing allocations (#2870)
* Various improvements to Classes, oriented around reducing allocations

- `push` no longer performs unnecessary allocations if `self` is empty.
    - Most constructors (FromIterator, From, Extend) are now oriented around push, to take advantage of this
- `to_string` and `into_prop_value`:
  - No longer allocate an unnecessary `Vec`; they instead preallocate a string of the correct length and push into it directly.
  - No longer use a length check + `unsafe`; they instead match over a fallible .next() and proceed from there.
  - Additionally, `into_prop_value` no longer builds a `String` or `Rc` if `Classes` contains a single `&'static str` or is empty.
- `From<String>` no longer clones the string if it contains a single class.
- `impl Eq for Classes`

* Fix duplicated is_empty test
2022-09-21 13:41:10 +09:00
Athan Clark
89dd3b3e7f
Simple NodeRef passing to <Link> for yew-router (#2877)
* simple NodeRef passing

* using `anchor_ref` opposed to `a_ref` per @futursolo's review
2022-09-19 03:05:23 +02:00
Kaede Hoshikawa
ce70e4c1fb
Resume Suspension upon unmount (#2874)
* Restore a behaviour of destroy upon unmount.

* Add a test.

* Fix CI.

* Fix CI.
2022-09-15 16:26:45 +03:00
Jens Reimann
beb0157c48
Allow skipping a callback when reforming (#2864)
* Allow skipping a callback when reforming

This adds a method to the callback, similar to Rust's filter_map, which
allows to reform a callback, but also suppress the emit in case
the reform function returns `None`.

* Update packages/yew/src/callback.rs

Co-authored-by: WorldSEnder <WorldSEnder@users.noreply.github.com>

* Implement filter_reform for all Callback output types

As suggested in the PR, this implements filter_reform for all output
types of callbacks by mapping to `Option<OUT>`.

* Fix clippy error

Although I believe that the code is more readable/understandable with
an explicit map, I am not sure adding a clippy exception just for that
is justified. So I applied the clippy suggestion.

Co-authored-by: WorldSEnder <WorldSEnder@users.noreply.github.com>
2022-09-15 01:14:58 +02:00
Cecile Tonglet
81f7ea482b
implement html from Option<VNode> (#2792)
Co-authored-by: Martin Molzer <WorldSEnder@users.noreply.github.com>
2022-09-14 18:04:12 +05:00
WorldSEnder
8eb9b5a4dc
Error on refs on components (#2863)
* error on `ref` with components

r#ref is still allowed, so we reserve the right to reintroduce
the syntax

* fix node_refs example
2022-09-13 16:50:33 +02:00
Kaede Hoshikawa
5f7dd1d972
Upgrade tokio to v1.21.1 (#2869)
* Remove tokio-util.

* Unpin tokio.

* Revert test workaround.
2022-09-13 16:49:39 +02:00
Muhammad Hamza
a489690d99
Pin tokio to 1.20.1 to fix CI (#2866) 2022-09-11 08:00:25 +09:00
Kaede Hoshikawa
278d2ce08e
Polled SSR Stream (#2824)
* Switch to pinned channels.

* Fix ServerRenderer so it's not blocked until the result is resolved.

* Fix tests.

* Remove unused SendError.

* Implement a stream to be polled alongside rendering.

* Update Buffer Size.

* Make Send renderer work.

* Remove pinned channels.

* Unified Naming.

* Optimise code.

* Restore capacity.

* Remove unused profile.

* Default to separate resolver.

* Reduce allocations on string.

* Adjust API.

* Remove duplicate trait bound.

* Update docs.

* Remove capacity setting.

* Unsafe?

* Separate files.

* Adjust inlining.

* Fix test.

* Update notice.

* Update documentation.

* Fix tests.
2022-09-11 01:25:00 +05:00
Cecile Tonglet
c7b4029e1b
Add old props to fn changed() (#2851)
* Adding old_props to fn changed()

* Change old_props type to &Self::Properties

* Update examples that use fn changed() and want old_props

* Fix tests

* Fix invalid test flags

* cargo fmt

* Oops wrong regex

* Revert change for older version

* Remove unnecessary clone

* Add migration guide

* Oh wow the test was not running xD
2022-08-31 17:10:45 +05:00
laizy
fc965435e8
Add send_stream method for Scope (#2619)
* add send_stream method for Scope

* add eof stream note

* map stream item type

* No need for nightly, fmt, updates

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>
2022-08-29 08:36:35 +09:00
Muhammad Hamza
0e0d6949f6
Allow functions returning unit in use_effect (#2849)
* Use TearDown trait as destructor for use_effect

* Docs

* no default tear_down
2022-08-28 19:33:42 +05:00
Kaede Hoshikawa
cffb7c5e7e
Configurable Runtime (#2772)
* Adds Runtime.

* A LocalRuntime.

* Add note.

* Add SSR benchmark.

* Only create default runtime if no custom runtime is set.

* Use jemalloc for benchmarking.

* Remove once_cell for web assembly.

* Add time.

* Fix wasm_bindgen.

* Adjust inlining.

* Optimise benchmark output.

* Optimise BufWriter.

* Add json output.

* Add Benchmark Workflow.

* Remove local set from tests.

* Fix Workflow syntax.

* Exclude benchmark from doc tests.

* Adjust feature flags.

* Adds a pinned channel implementation.

* Make Send bound explicit.

* Implement on immutable reference.

* Fix Sink close.

* run_pinned -> spawn_pinned.

* Add tests.

* Adjusts worker threads.

* Fix workflow.

* Remove futures-executor.

* Cargo update.

* Fix docs.

* Update notice.

* Fix docs.

* Fix docs.

* Switch to task spawning.

* Use futures unordered instead of spawn_local.

* Switch to join_all.

* Remove LocalPoolHandle.

* Fix docs.

* Spawn a single task.

* Fix merge failure.

* Remove LocalRuntime.

* Update documentation.

* Merge local-runtime-handle into local-runtime.

* Add some tests.

* Fix clippy notice.

* Fix comment.

* Address various review comments.

* Remove unused type.

* Fix clippy.

* Fix clippy.
2022-08-28 23:31:11 +09:00
Kaede Hoshikawa
5079885d9f
Pinned Channels (#2811)
* Switch to pinned channels.

* Fix ServerRenderer so it's not blocked until the result is resolved.

* Fix tests.

* Remove unused SendError.

* Revert channel-based BufWriter.

* Removed unused fmt module.

* Update docs.

* Add safety comments, adjust borrowing designs.

* Adjust oneshot as well.

* Fix workflow temporarily.

* Cell or UnsafeCell?

* Update safety notice.

* Should be sync.

* Actually should be both.

* Update packages/yew/src/platform/pinned/mpsc.rs

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

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>
2022-08-16 13:36:43 +09:00
Muhammad Hamza
4c35f95350
Bind to properties instead of attributes by default (#2819)
* Set to properties, not attributes

* fix tests

* Add tests

* enable disabled test, fmt

* Introduce @key syntax to forcefully set as attribute

* Everything compiles

* More tests

* id as property

* This was not meant to be committed

* Make test pass, fmt + clippy

* fucking rustfmt

* is this enough formatting

* that was not supposed to be commited

* apply review

* fmt

* fix CI

* will you be happy now, clippy?
2022-08-14 21:41:04 +02:00
Muhammad Hamza
a4e70914ac
Convert nightly from a feature flag to a compiler flag (#2827)
* `nightly_yew` compiler flag instead of `nightly` feature

* update ci

* update ci: 2

* fmt & nightly_yew for examples

* update size-cmp too
2022-08-15 04:03:45 +09:00
Kaede Hoshikawa
9e602b94ff
Reduce SSR Buffers in VList (#2826) 2022-08-14 23:38:36 +05:00
Kaede Hoshikawa
989d804947
Fix Clippy for 1.63 (#2825) 2022-08-12 22:16:05 +09:00
Muhammad Hamza
f640fc7c18
Allow keywords after dash in element and attribute names (#2820) 2022-08-08 23:36:10 +02:00
Muhammad Hamza
d422b533ea
onsubmit should be a SubmitEvent (#2816)
* onsubmit should be a SubmitEvent

* At least v0.3.59

* Enable feature, add re-export

* fmt
2022-08-08 02:10:38 +05:00
WorldSEnder
4206da7c41
Replace custom logging by tracing (#2814)
* use tracing for logging

* embed spans in the scheduler for tracing

* fix feature soundness

* remove spans from scheduler for now

* feature soundness take 2

* use tracing::* throughout lib code

not yet in testing, and for some errors!
2022-08-07 21:06:01 +02:00