Merge remote-tracking branch 'upstream/master' into fix_hot_reloading_svg_attributes
This commit is contained in:
commit
ab533864db
4 files changed
+95
-14
No files matched your search
@@ -402,12 +402,12 @@ impl<'b> DiffState<'b> {
|
|||||||
|
|
||||||
if old.listeners.len() == new.listeners.len() {
|
if old.listeners.len() == new.listeners.len() {
|
||||||
for (old_l, new_l) in old.listeners.iter().zip(new.listeners.iter()) {
|
for (old_l, new_l) in old.listeners.iter().zip(new.listeners.iter()) {
|
||||||
|
new_l.mounted_node.set(old_l.mounted_node.get());
|
||||||
if old_l.event != new_l.event {
|
if old_l.event != new_l.event {
|
||||||
self.mutations
|
self.mutations
|
||||||
.remove_event_listener(old_l.event, root.as_u64());
|
.remove_event_listener(old_l.event, root.as_u64());
|
||||||
self.mutations.new_event_listener(new_l, cur_scope_id);
|
self.mutations.new_event_listener(new_l, cur_scope_id);
|
||||||
}
|
}
|
||||||
new_l.mounted_node.set(old_l.mounted_node.get());
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for listener in old.listeners {
|
for listener in old.listeners {
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ lazy_static! {
|
|||||||
// the location of the code relative to the current crate based on [std::panic::Location]
|
// the location of the code relative to the current crate based on [std::panic::Location]
|
||||||
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct CodeLocation {
|
pub struct CodeLocation {
|
||||||
pub file: String,
|
pub crate_path: String,
|
||||||
|
pub file_path: String,
|
||||||
pub line: u32,
|
pub line: u32,
|
||||||
pub column: u32,
|
pub column: u32,
|
||||||
}
|
}
|
||||||
@@ -83,14 +84,12 @@ macro_rules! get_line_num {
|
|||||||
() => {{
|
() => {{
|
||||||
let line = line!();
|
let line = line!();
|
||||||
let column = column!();
|
let column = column!();
|
||||||
let file = file!();
|
let file_path = file!().to_string();
|
||||||
|
let crate_path = env!("CARGO_MANIFEST_DIR").to_string();
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
let file = env!("CARGO_MANIFEST_DIR").to_string() + "\\" + file!();
|
|
||||||
#[cfg(unix)]
|
|
||||||
let file = env!("CARGO_MANIFEST_DIR").to_string() + "/" + file!();
|
|
||||||
CodeLocation {
|
CodeLocation {
|
||||||
file: file.to_string(),
|
crate_path,
|
||||||
|
file_path,
|
||||||
line: line,
|
line: line,
|
||||||
column: column,
|
column: column,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ fn render_basic() {
|
|||||||
let dom = VirtualDom::new(Base);
|
let dom = VirtualDom::new(Base);
|
||||||
let static_vnodes = rsx!(div{"hello world"});
|
let static_vnodes = rsx!(div{"hello world"});
|
||||||
let location = CodeLocation {
|
let location = CodeLocation {
|
||||||
file: String::new(),
|
file_path: String::new(),
|
||||||
|
crate_path: String::new(),
|
||||||
line: 0,
|
line: 0,
|
||||||
column: 0,
|
column: 0,
|
||||||
};
|
};
|
||||||
@@ -55,7 +56,8 @@ fn render_nested() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
let location = CodeLocation {
|
let location = CodeLocation {
|
||||||
file: String::new(),
|
file_path: String::new(),
|
||||||
|
crate_path: String::new(),
|
||||||
line: 1,
|
line: 1,
|
||||||
column: 0,
|
column: 0,
|
||||||
};
|
};
|
||||||
@@ -106,7 +108,8 @@ fn render_component() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
let location = CodeLocation {
|
let location = CodeLocation {
|
||||||
file: String::new(),
|
file_path: String::new(),
|
||||||
|
crate_path: String::new(),
|
||||||
line: 2,
|
line: 2,
|
||||||
column: 0,
|
column: 0,
|
||||||
};
|
};
|
||||||
@@ -157,7 +160,8 @@ fn render_iterator() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
let location = CodeLocation {
|
let location = CodeLocation {
|
||||||
file: String::new(),
|
file_path: String::new(),
|
||||||
|
crate_path: String::new(),
|
||||||
line: 3,
|
line: 3,
|
||||||
column: 0,
|
column: 0,
|
||||||
};
|
};
|
||||||
@@ -210,7 +214,8 @@ fn render_captured_variable() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
let location = CodeLocation {
|
let location = CodeLocation {
|
||||||
file: String::new(),
|
file_path: String::new(),
|
||||||
|
crate_path: String::new(),
|
||||||
line: 4,
|
line: 4,
|
||||||
column: 0,
|
column: 0,
|
||||||
};
|
};
|
||||||
@@ -261,7 +266,8 @@ fn render_listener() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
let location = CodeLocation {
|
let location = CodeLocation {
|
||||||
file: String::new(),
|
file_path: String::new(),
|
||||||
|
crate_path: String::new(),
|
||||||
line: 5,
|
line: 5,
|
||||||
column: 0,
|
column: 0,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -756,3 +756,79 @@ fn add_nested_elements() {
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn add_listeners() {
|
||||||
|
let vdom = new_dom();
|
||||||
|
|
||||||
|
let (_create, change) = vdom.diff_lazynodes(
|
||||||
|
rsx! {
|
||||||
|
div{}
|
||||||
|
},
|
||||||
|
rsx! {
|
||||||
|
div{
|
||||||
|
onkeyup: |_| {},
|
||||||
|
onkeydown: |_| {},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
change.edits,
|
||||||
|
[
|
||||||
|
NewEventListener { event_name: "keyup", scope: ScopeId(0), root: 1 },
|
||||||
|
NewEventListener { event_name: "keydown", scope: ScopeId(0), root: 1 },
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn remove_listeners() {
|
||||||
|
let vdom = new_dom();
|
||||||
|
|
||||||
|
let (_create, change) = vdom.diff_lazynodes(
|
||||||
|
rsx! {
|
||||||
|
div{
|
||||||
|
onkeyup: |_| {},
|
||||||
|
onkeydown: |_| {},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
rsx! {
|
||||||
|
div{}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
change.edits,
|
||||||
|
[
|
||||||
|
RemoveEventListener { event: "keyup", root: 1 },
|
||||||
|
RemoveEventListener { event: "keydown", root: 1 },
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn diff_listeners() {
|
||||||
|
let vdom = new_dom();
|
||||||
|
|
||||||
|
let (_create, change) = vdom.diff_lazynodes(
|
||||||
|
rsx! {
|
||||||
|
div{
|
||||||
|
onkeydown: |_| {},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
rsx! {
|
||||||
|
div{
|
||||||
|
onkeyup: |_| {},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
change.edits,
|
||||||
|
[
|
||||||
|
RemoveEventListener { root: 1, event: "keydown" },
|
||||||
|
NewEventListener { event_name: "keyup", scope: ScopeId(0), root: 1 }
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in new issue
Block a user