mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-24 19:25:12 +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(
|
document.querySelector('body').addEventListener(
|
||||||
'click',
|
'click',
|
||||||
function (e) {
|
function (e) {
|
||||||
var target = e.target
|
let target = e.target
|
||||||
|
const baseTarget = document.querySelector('head base')?.target
|
||||||
while (target != null) {
|
while (target != null) {
|
||||||
if (target.matches('a')) {
|
if (target.matches('a')) {
|
||||||
if (
|
if (
|
||||||
target.href &&
|
target.href &&
|
||||||
(['http://', 'https://', 'mailto:', 'tel:'].some(v => target.href.startsWith(v))) &&
|
(['http://', 'https://', 'mailto:', 'tel:'].some(v => target.href.startsWith(v))) &&
|
||||||
target.target === '_blank'
|
(target.target === '_blank' || (!target.target && baseTarget === "_blank"))
|
||||||
) {
|
) {
|
||||||
window.__TAURI_INVOKE__('tauri', {
|
window.__TAURI_INVOKE__('tauri', {
|
||||||
__tauriModule: 'Shell',
|
__tauriModule: 'Shell',
|
||||||
|
Loading…
Reference in New Issue
Block a user