summaryrefslogtreecommitdiff
path: root/ext/js/app/popup-factory.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/app/popup-factory.js')
-rw-r--r--ext/js/app/popup-factory.js21
1 files changed, 10 insertions, 11 deletions
diff --git a/ext/js/app/popup-factory.js b/ext/js/app/popup-factory.js
index c5187291..4338bb3a 100644
--- a/ext/js/app/popup-factory.js
+++ b/ext/js/app/popup-factory.js
@@ -29,15 +29,12 @@ export class PopupFactory {
/**
* Creates a new instance.
* @param {import('../application.js').Application} application
- * @param {number} frameId The frame ID of the host frame.
*/
- constructor(application, frameId) {
+ constructor(application) {
/** @type {import('../application.js').Application} */
this._application = application;
- /** @type {number} */
- this._frameId = frameId;
/** @type {FrameOffsetForwarder} */
- this._frameOffsetForwarder = new FrameOffsetForwarder(application.crossFrame, frameId);
+ this._frameOffsetForwarder = new FrameOffsetForwarder(application.crossFrame);
/** @type {Map<string, import('popup').PopupAny>} */
this._popups = new Map();
/** @type {Map<string, {popup: import('popup').PopupAny, token: string}[]>} */
@@ -115,6 +112,9 @@ export class PopupFactory {
depth = 0;
}
+ const currentFrameId = this._application.frameId;
+ if (currentFrameId === null) { throw new Error('Cannot create popup: no frameId'); }
+
if (popupWindow) {
// New unique id
if (id === null) {
@@ -124,11 +124,11 @@ export class PopupFactory {
application: this._application,
id,
depth,
- frameId: this._frameId
+ frameId: currentFrameId
});
this._popups.set(id, popup);
return popup;
- } else if (frameId === this._frameId) {
+ } else if (frameId === currentFrameId) {
// New unique id
if (id === null) {
id = generateId(16);
@@ -137,7 +137,7 @@ export class PopupFactory {
application: this._application,
id,
depth,
- frameId: this._frameId,
+ frameId: currentFrameId,
childrenSupported
});
if (parent !== null) {
@@ -155,13 +155,12 @@ export class PopupFactory {
throw new Error('Invalid frameId');
}
const useFrameOffsetForwarder = (parentPopupId === null);
- /** @type {{id: string, depth: number, frameId: number}} */
- const info = await this._application.crossFrame.invoke(frameId, 'popupFactoryGetOrCreatePopup', /** @type {import('popup-factory').GetOrCreatePopupDetails} */ ({
+ const info = await this._application.crossFrame.invoke(frameId, 'popupFactoryGetOrCreatePopup', {
id,
parentPopupId,
frameId,
childrenSupported
- }));
+ });
id = info.id;
const popup = new PopupProxy({
application: this._application,