summaryrefslogtreecommitdiff
path: root/ext/fg
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2020-03-09 12:16:01 +0200
committerGitHub <noreply@github.com>2020-03-09 12:16:01 +0200
commit7541517d8084b50e054393f3b4fa6d4630ad012e (patch)
tree8b57533971269944898ce0365f07d3d95962166c /ext/fg
parent0112dbab33ab214f9e1dc930558833956d4ad1c4 (diff)
parent2ca88b9b9f2a6152e8e953cac284f31c8a285446 (diff)
Merge pull request #405 from siikamiika/fix-popup-depth-search-page
start popup depth from 1 on search page
Diffstat (limited to 'ext/fg')
-rw-r--r--ext/fg/js/frontend-initialize.js2
-rw-r--r--ext/fg/js/popup-proxy-host.js11
2 files changed, 10 insertions, 3 deletions
diff --git a/ext/fg/js/frontend-initialize.js b/ext/fg/js/frontend-initialize.js
index bbb789cc..e674724e 100644
--- a/ext/fg/js/frontend-initialize.js
+++ b/ext/fg/js/frontend-initialize.js
@@ -31,7 +31,7 @@ async function main() {
const popupHost = new PopupProxyHost();
await popupHost.prepare();
- popup = popupHost.getOrCreatePopup();
+ popup = popupHost.getOrCreatePopup(null, null, depth);
}
const frontend = new Frontend(popup, ignoreNodes);
diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js
index 7d86aa67..49123ee1 100644
--- a/ext/fg/js/popup-proxy-host.js
+++ b/ext/fg/js/popup-proxy-host.js
@@ -47,7 +47,7 @@ class PopupProxyHost {
]));
}
- getOrCreatePopup(id=null, parentId=null) {
+ getOrCreatePopup(id=null, parentId=null, depth=null) {
// Find by existing id
if (id !== null) {
const popup = this._popups.get(id);
@@ -76,7 +76,14 @@ class PopupProxyHost {
}
// Create new popup
- const depth = (parent !== null ? parent.depth + 1 : 0);
+ if (parent !== null) {
+ if (depth !== null) {
+ throw new Error('Depth cannot be set when parent exists');
+ }
+ depth = parent.depth + 1;
+ } else if (depth === null) {
+ depth = 0;
+ }
const popup = new Popup(id, depth, this._frameIdPromise);
if (parent !== null) {
popup.setParent(parent);