chore: clean up examples and fix link opening code
This commit is contained in:
1 parent
cc99fa8eb2
commit
6905bf98d7
7 files changed
+28
-31
No files matched your search
@@ -200,14 +200,35 @@ export class Interpreter {
|
||||
let target = event.target;
|
||||
if (target != null) {
|
||||
let realId = target.getAttribute(`data-dioxus-id`);
|
||||
let shouldPreventDefault = target.getAttribute(
|
||||
`dioxus-prevent-default`
|
||||
);
|
||||
|
||||
if (event.type == "click") {
|
||||
event.preventDefault();
|
||||
if (shouldPreventDefault !== `onclick`) {
|
||||
console.log("click", event);
|
||||
console.log("clickeded", event.target);
|
||||
console.log("clickeded", event.target.tagName);
|
||||
if (target.tagName == "A") {
|
||||
const href = target.getAttribute("href");
|
||||
if (href !== "" && href !== null && href !== undefined) {
|
||||
window.rpc.call("browser_open", { href });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// walk the tree to find the real element
|
||||
while (realId == null && target.parentElement != null) {
|
||||
target = target.parentElement;
|
||||
realId = target.getAttribute(`data-dioxus-id`);
|
||||
}
|
||||
const shouldPreventDefault = target.getAttribute(
|
||||
|
||||
shouldPreventDefault = target.getAttribute(
|
||||
`dioxus-prevent-default`
|
||||
);
|
||||
|
||||
let contents = serialize_event(event);
|
||||
if (shouldPreventDefault === `on${event.type}`) {
|
||||
event.preventDefault();
|
||||
@@ -215,25 +236,6 @@ export class Interpreter {
|
||||
if (event.type == "submit") {
|
||||
event.preventDefault();
|
||||
}
|
||||
if (event.type == "click") {
|
||||
event.preventDefault();
|
||||
if (shouldPreventDefault !== `onclick`) {
|
||||
if (target.tagName == "A") {
|
||||
const href = target.getAttribute("href");
|
||||
if (
|
||||
href !== "" &&
|
||||
href !== null &&
|
||||
href !== undefined &&
|
||||
realId != null
|
||||
) {
|
||||
window.rpc.call("browser_open", {
|
||||
mounted_dom_id: parseInt(realId),
|
||||
href,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (realId == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -188,6 +188,7 @@ pub fn launch_with_props<P: 'static + Send>(
|
||||
let _ = proxy.send_event(UserWindowEvent::Update);
|
||||
}
|
||||
"browser_open" => {
|
||||
println!("browser_open");
|
||||
let data = req.params.unwrap();
|
||||
log::trace!("Open browser: {:?}", data);
|
||||
if let Some(arr) = data.as_array() {
|
||||
|
||||
Reference in new issue
Block a user