Comments (4)
To clarify: Do you mean optional props on a component or optional attributes on a DOM element?
Both should actually already be possible so if you have an example of where it's not working I'd be happy to take a look!
from leptos.
Sorry I didn't see the second half of the title when I posted this response, clearly.
Option<T>
is support on attributes when T
is a primitive type. It's supported on properties when T
is a primitive or JsValue
.
I don't support it on event listeners at the moment; note that Leptos is using global event delegation, so it's not actually adding an event listener on the element. (It does create the closure for the event listener once per instance and store it in the DOM, to be fair.)
For an event listener you'd actually need to support Fn() -> Option<Fn(web_sys::Event)>
which seems a little messy to me. (Because a simple Option<Fn(web_sys::Event)
isn't dynamic, since components don't re-run.)
from leptos.
I see it does in fact work! I didn't try it because I didn't see it in the docs. It wasn't until I checked the trait implementations for IntoAttribute
that I saw it was implemented for many primitive types.
from leptos.
Great! I'll add something to the docs, too.
from leptos.
Related Issues (20)
- Invalid `KeyboardEvent` type when triggering autocomplete HOT 3
- Allow multiple classes in the class-tuple syntax HOT 4
- Inconsistent behaviour for buttons with formmethod="dialog" rendered on the client HOT 1
- NodeRef on_load panics when ref is remounted HOT 2
- DX regression in view macro for rust-analyzer 2024-03-18 (v0.3.1885) and newer HOT 5
- Access environment variables in CSR HOT 1
- There is a bug in Safari browser where signals cannot be transmitted properly HOT 1
- DynChild is populated as a single Child in the components' children property HOT 4
- Breaking change in view macro between 0.6.10 and 0.6.11
- Allow custom derive for server_fns with custom encoding HOT 3
- Add Trigger::dispose
- leptos_macro 0.6.11 leptos::view! breaks with some comments
- Non-'static signals
- the format!() bug in <a href={format!()}> HOT 2
- Effects/Memos should't be able to "own" a signal HOT 4
- Nested Suspense ignores SSR Mode and breaks Hydration HOT 2
- Error when running server function inside spawn_local HOT 5
- Click events are registered twice when two leptos custom elements are on a page HOT 3
- about mobile support
- Recursive effects never run after recursing HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from leptos.