From 9e04ce5342850d2e0a01dde169807d6f6eb16566 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Tue, 18 Jan 2022 09:32:27 +0800 Subject: [PATCH] feat: `open_browser` bool attribute --- examples/link.rs | 1 + packages/desktop/src/index.js | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/examples/link.rs b/examples/link.rs index da4b5b459..49921f98a 100644 --- a/examples/link.rs +++ b/examples/link.rs @@ -16,6 +16,7 @@ fn app(cx: Scope) -> Element { p { a { href: "http://dioxuslabs.com/", + "browser-open": "false", onclick: |_| { println!("Hello Dioxus"); }, diff --git a/packages/desktop/src/index.js b/packages/desktop/src/index.js index d15fc39b0..c141f56d4 100644 --- a/packages/desktop/src/index.js +++ b/packages/desktop/src/index.js @@ -414,10 +414,15 @@ class Interpreter { const target = event.target; const real_id = target.getAttribute(`dioxus-id`); - rpc.call("browser_open", { - mounted_dom_id: parseInt(real_id), - href: target.getAttribute("browser-href"), - }) + if (target.getAttribute("browser-open") != "false") { + rpc.call("browser_open", { + mounted_dom_id: parseInt(real_id), + href: target.getAttribute("browser-href"), + }); + } else { + window.location = target.getAttribute("browser-href"); + } + }) } else {