Maurice Kayser 2 năm trước cách đây
mục cha
commit
c8f88b6428

+ 1 - 1
docs/guide/examples/event_nested.rs

@@ -14,7 +14,7 @@ fn App(cx: Scope) -> Element {
             button {
                 onclick: move |event| {
                     // now, outer won't be triggered
-                    event.stop_propogation();
+                    event.stop_propagation();
                 },
                 "inner"
             }

+ 5 - 5
examples/nested_listeners.rs

@@ -16,18 +16,18 @@ fn app(cx: Scope) -> Element {
             onclick: move |_| println!("clicked! top"),
             "- div"
             button {
-                onclick: move |_| println!("clicked! bottom propoate"),
-                "Propogate"
+                onclick: move |_| println!("clicked! bottom propagate"),
+                "Propagate"
             }
             button {
                 onclick: move |evt| {
                     println!("clicked! bottom no bubbling");
-                    evt.stop_propogation();
+                    evt.stop_propagation();
                 },
-                "Dont propogate"
+                "Dont propagate"
             }
             button {
-                "Does not handle clicks - only propogate"
+                "Does not handle clicks - only propagate"
             }
         }
     })

+ 6 - 6
examples/window_event.rs

@@ -35,13 +35,13 @@ fn app(cx: Scope) -> Element {
                 nav { class: "md:ml-auto flex flex-wrap items-center text-base justify-center" }
                 button {
                     class: "inline-flex items-center bg-gray-800 border-0 py-1 px-3 focus:outline-none hover:bg-gray-700 rounded text-base mt-4 md:mt-0",
-                    onmousedown: |evt| evt.stop_propogation(),
+                    onmousedown: |evt| evt.stop_propagation(),
                     onclick: move |_| window.set_minimized(true),
                     "Minimize"
                 }
                 button {
                     class: "inline-flex items-center bg-gray-800 border-0 py-1 px-3 focus:outline-none hover:bg-gray-700 rounded text-base mt-4 md:mt-0",
-                    onmousedown: |evt| evt.stop_propogation(),
+                    onmousedown: |evt| evt.stop_propagation(),
                     onclick: move |_| {
 
                         window.set_fullscreen(!**fullscreen);
@@ -52,7 +52,7 @@ fn app(cx: Scope) -> Element {
                 }
                 button {
                     class: "inline-flex items-center bg-gray-800 border-0 py-1 px-3 focus:outline-none hover:bg-gray-700 rounded text-base mt-4 md:mt-0",
-                    onmousedown: |evt| evt.stop_propogation(),
+                    onmousedown: |evt| evt.stop_propagation(),
                     onclick: move |_| window.close(),
                     "Close"
                 }
@@ -66,7 +66,7 @@ fn app(cx: Scope) -> Element {
                 div {
                     button {
                         class: "inline-flex items-center text-white bg-green-500 border-0 py-1 px-3 hover:bg-green-700 rounded",
-                        onmousedown: |evt| evt.stop_propogation(),
+                        onmousedown: |evt| evt.stop_propagation(),
                         onclick: move |_| {
                             window.set_always_on_top(!always_on_top);
                             always_on_top.set(!always_on_top);
@@ -77,7 +77,7 @@ fn app(cx: Scope) -> Element {
                 div {
                     button {
                         class: "inline-flex items-center text-white bg-blue-500 border-0 py-1 px-3 hover:bg-green-700 rounded",
-                        onmousedown: |evt| evt.stop_propogation(),
+                        onmousedown: |evt| evt.stop_propagation(),
                         onclick: move |_| {
                             window.set_decorations(!decorations);
                             decorations.set(!decorations);
@@ -88,7 +88,7 @@ fn app(cx: Scope) -> Element {
                 div {
                     button {
                         class: "inline-flex items-center text-white bg-blue-500 border-0 py-1 px-3 hover:bg-green-700 rounded",
-                        onmousedown: |evt| evt.stop_propogation(),
+                        onmousedown: |evt| evt.stop_propagation(),
                         onclick: move |_| window.set_title("Dioxus Application"),
                         "Change Title"
                     }

+ 7 - 7
packages/core/src/events.rs

@@ -23,7 +23,7 @@ use std::{
 pub struct Event<T: 'static + ?Sized> {
     /// The data associated with this event
     pub data: Rc<T>,
-    pub(crate) propogates: Rc<Cell<bool>>,
+    pub(crate) propagates: Rc<Cell<bool>>,
 }
 
 impl<T> Event<T> {
@@ -40,9 +40,9 @@ impl<T> Event<T> {
     ///     }
     /// }
     /// ```
-    #[deprecated = "use stop_propogation instead"]
+    #[deprecated = "use stop_propagation instead"]
     pub fn cancel_bubble(&self) {
-        self.propogates.set(false);
+        self.propagates.set(false);
     }
 
     /// Prevent this event from continuing to bubble up the tree to parent elements.
@@ -58,8 +58,8 @@ impl<T> Event<T> {
     ///     }
     /// }
     /// ```
-    pub fn stop_propogation(&self) {
-        self.propogates.set(false);
+    pub fn stop_propagation(&self) {
+        self.propagates.set(false);
     }
 
     /// Get a reference to the inner data from this event
@@ -84,7 +84,7 @@ impl<T> Event<T> {
 impl<T: ?Sized> Clone for Event<T> {
     fn clone(&self) -> Self {
         Self {
-            propogates: self.propogates.clone(),
+            propagates: self.propagates.clone(),
             data: self.data.clone(),
         }
     }
@@ -100,7 +100,7 @@ impl<T> std::ops::Deref for Event<T> {
 impl<T: std::fmt::Debug> std::fmt::Debug for Event<T> {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         f.debug_struct("UiEvent")
-            .field("bubble_state", &self.propogates)
+            .field("bubble_state", &self.propagates)
             .field("data", &self.data)
             .finish()
     }

+ 1 - 1
packages/core/src/scopes.rs

@@ -499,7 +499,7 @@ impl<'src> ScopeState {
             BumpBox::from_raw(self.bump().alloc(move |event: Event<dyn Any>| {
                 if let Ok(data) = event.data.downcast::<T>() {
                     callback(Event {
-                        propogates: event.propogates,
+                        propagates: event.propagates,
                         data,
                     })
                 }

+ 2 - 2
packages/core/src/virtual_dom.rs

@@ -347,7 +347,7 @@ impl VirtualDom {
 
         // We will clone this later. The data itself is wrapped in RC to be used in callbacks if required
         let uievent = Event {
-            propogates: Rc::new(Cell::new(bubbles)),
+            propagates: Rc::new(Cell::new(bubbles)),
             data,
         };
 
@@ -388,7 +388,7 @@ impl VirtualDom {
                         cb(uievent.clone());
                     }
 
-                    if !uievent.propogates.get() {
+                    if !uievent.propagates.get() {
                         return;
                     }
                 }

+ 1 - 1
packages/hooks/src/useref.rs

@@ -170,7 +170,7 @@ impl<T> UseRef<T> {
 
     /// Set the curernt value to `new_value`. This will mark the component as "dirty"
     ///
-    /// This change will propogate immediately, so any other contexts that are
+    /// This change will propagate immediately, so any other contexts that are
     /// using this RefCell will also be affected. If called during an async context,
     /// the component will not be re-rendered until the next `.await` call.
     pub fn set(&self, new: T) {