mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-19 00:21:32 +03:00
* feat: respect `base` tag's `target` attribute, closes #7285 * Update core.js * fix condition
This commit is contained in:
parent
fa7f9b77ab
commit
757e959eb2
5
.changes/core-base-links-target.md
Normal file
5
.changes/core-base-links-target.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
'tauri': 'minor:enhance'
|
||||
---
|
||||
|
||||
Open links externally when `<base target="_blank" />` exists
|
@ -91,13 +91,14 @@
|
||||
document.querySelector('body').addEventListener(
|
||||
'click',
|
||||
function (e) {
|
||||
var target = e.target
|
||||
let target = e.target
|
||||
const baseTarget = document.querySelector('head base')?.target
|
||||
while (target != null) {
|
||||
if (target.matches('a')) {
|
||||
if (
|
||||
target.href &&
|
||||
(['http://', 'https://', 'mailto:', 'tel:'].some(v => target.href.startsWith(v))) &&
|
||||
target.target === '_blank'
|
||||
(target.target === '_blank' || (!target.target && baseTarget === "_blank"))
|
||||
) {
|
||||
window.__TAURI_INVOKE__('tauri', {
|
||||
__tauriModule: 'Shell',
|
||||
|
Loading…
Reference in New Issue
Block a user