Merge pull request #405 from siikamiika/fix-popup-depth-search-page

start popup depth from 1 on search page
This commit is contained in:
siikamiika 2020-03-09 12:16:01 +02:00 committed by GitHub
commit 7541517d80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -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);

View File

@ -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);