Describe the bug
It is currently possible to create multiple instances of WebviewWindow with the same label.
This could lead to undefined behavior when we consider that WebviewWindow.getByLabel() returns a single handle.
Alternatively, WebviewWindow.getByLabel() could be changed to return an array if there are multiple windows with that label.
To Reproduce
Steps to reproduce the behavior:
Within a tauri app, execute the following js:
import { getCurrent, WebviewWindow } from '@tauri-apps/api/window';
async function testFunction() {
const label = 'testlabel' // the label that will be shared between multiple windows
const webview1 = new WebviewWindow(label);
const webview2 = new WebviewWindow(label);
// we now have two webviews with the same label.
}
Expected behavior
The WebviewWindow constructor should throw an error if the label is duplicated.
Alternatively, if we decide to allow duplicated labels, WebviewWindow.getByLabel() should return an array.
Platform and Versions (please complete the following information):
Operating System - Windows, version 10.0.19042 X64
Webview2 - 91.0.864.54
Node.js environment
Node.js - 14.16.1
@tauri-apps/cli - 1.0.0-beta.3
@tauri-apps/api - 1.0.0-beta.2
Global packages
npm - 6.14.12
yarn - 1.22.10
Rust environment
rustc - 1.53.0
cargo - 1.53.0
Additional context
Allowing duplicate labels would permit that the label be a description of the window's role (eg. main, auxiliary, print_preview)
Disallowing duplicate labels ensures a unique window identifier.
Currently we can achieve the best of both worlds by using a patterns such as <role>:<id> so I think it is best we simply enforce uniqueness.
Describe the bug
It is currently possible to create multiple instances of
WebviewWindowwith the same label.This could lead to undefined behavior when we consider that
WebviewWindow.getByLabel()returns a single handle.Alternatively,
WebviewWindow.getByLabel()could be changed to return an array if there are multiple windows with that label.To Reproduce
Steps to reproduce the behavior:
Within a tauri app, execute the following js:
Expected behavior
The WebviewWindow constructor should throw an error if the label is duplicated.
Alternatively, if we decide to allow duplicated labels,
WebviewWindow.getByLabel()should return an array.Platform and Versions (please complete the following information):
Operating System - Windows, version 10.0.19042 X64
Webview2 - 91.0.864.54
Node.js environment
Node.js - 14.16.1
@tauri-apps/cli - 1.0.0-beta.3
@tauri-apps/api - 1.0.0-beta.2
Global packages
npm - 6.14.12
yarn - 1.22.10
Rust environment
rustc - 1.53.0
cargo - 1.53.0
Additional context
Allowing duplicate labels would permit that the label be a description of the window's role (eg. main, auxiliary, print_preview)
Disallowing duplicate labels ensures a unique window identifier.
Currently we can achieve the best of both worlds by using a patterns such as
<role>:<id>so I think it is best we simply enforce uniqueness.