mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 14:54:16 +00:00
Merge branch 'leptos_dom_v2' of https://github.com/jquesada2016/leptos into leptos_dom_v2
This commit is contained in:
commit
982cec9507
3 changed files with 83 additions and 62 deletions
|
@ -25,7 +25,7 @@ pub trait EventDescriptor {
|
|||
|
||||
/// Overrides the [`EventDescriptor::bubbles`] method to always return
|
||||
/// `false`, which forces the event to not be globally delegated.
|
||||
pub struct Undelegated<Ev: EventDescriptor>(Ev);
|
||||
pub struct Undelegated<Ev: EventDescriptor>(pub Ev);
|
||||
|
||||
impl<Ev: EventDescriptor> EventDescriptor for Undelegated<Ev> {
|
||||
type EventType = Ev::EventType;
|
||||
|
@ -97,32 +97,32 @@ generate_event_types![
|
|||
],
|
||||
[KeyboardEvent, [KeyDown, Keypress, Keyup]],
|
||||
[FocusEvent, [Focus, FocusOut, FocusIn, Blur]],
|
||||
[FormEvent, [Change, Input, Invalid, Reset, Submit]],
|
||||
[
|
||||
MouseEvent,
|
||||
[
|
||||
Click,
|
||||
ContextMenu,
|
||||
DoubleClick,
|
||||
DblClick,
|
||||
Drag,
|
||||
DragEnd,
|
||||
DragEnter,
|
||||
DragExit,
|
||||
DragLeave,
|
||||
DragOver,
|
||||
DragStart,
|
||||
Drop,
|
||||
MouseDown,
|
||||
MouseEnter,
|
||||
MouseLeave,
|
||||
MouseMove,
|
||||
MouseOut,
|
||||
MouseOver,
|
||||
MouseUp,
|
||||
]
|
||||
],
|
||||
[ScrollEvent, [Scroll]],
|
||||
// [FormEvent, [Change, Input, Invalid, Reset, Submit]],
|
||||
// [
|
||||
// MouseEvent,
|
||||
// [
|
||||
// Click,
|
||||
// ContextMenu,
|
||||
// DoubleClick,
|
||||
// DblClick,
|
||||
// Drag,
|
||||
// DragEnd,
|
||||
// DragEnter,
|
||||
// DragExit,
|
||||
// DragLeave,
|
||||
// DragOver,
|
||||
// DragStart,
|
||||
// Drop,
|
||||
// MouseDown,
|
||||
// MouseEnter,
|
||||
// MouseLeave,
|
||||
// MouseMove,
|
||||
// MouseOut,
|
||||
// MouseOver,
|
||||
// MouseUp,
|
||||
// ]
|
||||
// ],
|
||||
// [ScrollEvent, [Scroll]],
|
||||
[
|
||||
PointerEvent,
|
||||
[
|
||||
|
@ -138,41 +138,41 @@ generate_event_types![
|
|||
PointerOut,
|
||||
]
|
||||
],
|
||||
[SelectionEvent, [Select]],
|
||||
// [SelectionEvent, [Select]],
|
||||
[TouchEvent, [TouchCancel, TouchEnd, TouchMove, TouchStart]],
|
||||
[WheelEvent, [Wheel]],
|
||||
[
|
||||
MediaEvent,
|
||||
[
|
||||
Abort,
|
||||
CanPlay,
|
||||
CanPlayThrough,
|
||||
DurationChange,
|
||||
Emptied,
|
||||
Encrypted,
|
||||
Ended,
|
||||
Error,
|
||||
LoadedData,
|
||||
LoadedMetadata,
|
||||
LoadStart,
|
||||
Pause,
|
||||
Play,
|
||||
Playing,
|
||||
Progress,
|
||||
RateChange,
|
||||
Seeked,
|
||||
Seeking,
|
||||
Stalled,
|
||||
Suspend,
|
||||
TimeUpdate,
|
||||
VolumeChange,
|
||||
Waiting,
|
||||
]
|
||||
],
|
||||
// [
|
||||
// MediaEvent,
|
||||
// [
|
||||
// Abort,
|
||||
// CanPlay,
|
||||
// CanPlayThrough,
|
||||
// DurationChange,
|
||||
// Emptied,
|
||||
// Encrypted,
|
||||
// Ended,
|
||||
// Error,
|
||||
// LoadedData,
|
||||
// LoadedMetadata,
|
||||
// LoadStart,
|
||||
// Pause,
|
||||
// Play,
|
||||
// Playing,
|
||||
// Progress,
|
||||
// RateChange,
|
||||
// Seeked,
|
||||
// Seeking,
|
||||
// Stalled,
|
||||
// Suspend,
|
||||
// TimeUpdate,
|
||||
// VolumeChange,
|
||||
// Waiting,
|
||||
// ]
|
||||
// ],
|
||||
[
|
||||
AnimationEvent,
|
||||
[AnimationStart, AnimationEnd, AnimationIteration,]
|
||||
],
|
||||
[TransitionEvent, [TransitionEnd]],
|
||||
[ToggleEvent, [Toggle]]
|
||||
// [ToggleEvent, [Toggle]]
|
||||
];
|
||||
|
|
|
@ -15,7 +15,7 @@ use std::{
|
|||
fmt,
|
||||
ops::Deref,
|
||||
};
|
||||
use wasm_bindgen::{convert::FromWasmAbi, intern, JsCast};
|
||||
use wasm_bindgen::{convert::FromWasmAbi, intern, JsCast, JsValue};
|
||||
|
||||
/// Trait alias for the trait bounts on [`IntoElement`].
|
||||
#[cfg(all(target_arch = "wasm32", feature = "web"))]
|
||||
|
@ -370,6 +370,27 @@ impl<El: IntoElement> HtmlElement<El> {
|
|||
self.dyn_attr("class", f)
|
||||
}
|
||||
|
||||
/// Adds a prop to this element.
|
||||
#[track_caller]
|
||||
pub fn prop(
|
||||
self,
|
||||
name: impl Into<Cow<'static, str>>,
|
||||
value: impl Into<JsValue>,
|
||||
) -> Self {
|
||||
#[cfg(all(target_arch = "wasm32", feature = "web"))]
|
||||
{
|
||||
let name = name.into();
|
||||
let value = value.into();
|
||||
|
||||
let name: &str = &name;
|
||||
|
||||
js_sys::Reflect::set(&self, &name.into(), &value)
|
||||
.expect("set property to not err");
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
/// Adds an event listener to this element.
|
||||
#[track_caller]
|
||||
pub fn on<E: EventDescriptor + 'static>(
|
||||
|
|
|
@ -21,18 +21,18 @@ use cfg_if::cfg_if;
|
|||
pub use components::*;
|
||||
pub use events::typed as ev;
|
||||
pub use html::*;
|
||||
pub use node_ref::*;
|
||||
pub use logging::*;
|
||||
pub use web_sys;
|
||||
pub use wasm_bindgen;
|
||||
use leptos_reactive::Scope;
|
||||
pub use logging::*;
|
||||
pub use node_ref::*;
|
||||
use smallvec::SmallVec;
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
cell::{LazyCell, OnceCell},
|
||||
fmt,
|
||||
};
|
||||
pub use wasm_bindgen;
|
||||
use wasm_bindgen::{JsCast, UnwrapThrowExt};
|
||||
pub use web_sys;
|
||||
|
||||
#[thread_local]
|
||||
static COMMENT: LazyCell<web_sys::Node> =
|
||||
|
|
Loading…
Reference in a new issue