Remove nested Promise

This commit is contained in:
Dmitry Lyzo 2020-09-02 01:06:07 +03:00
parent eccaad366e
commit 748592fa93

View File

@ -36,7 +36,6 @@ import 'css!components/viewManager/viewContainer';
const newViewInfo = normalizeNewView(options, isPluginpage);
const newView = newViewInfo.elem;
return new Promise((resolve) => {
const currentPage = allPages[pageIndex];
if (currentPage) {
@ -82,8 +81,11 @@ import 'css!components/viewManager/viewContainer';
}
allPages[pageIndex] = view;
return setControllerClass(view, options)
// Timeout for polyfilled CustomElements (webOS 1.2)
setControllerClass(view, options).then(() => new Promise((resolve) => setTimeout(resolve, 0))).then(() => {
.then(() => new Promise((resolve) => setTimeout(resolve, 0)))
.then(() => {
if (onBeforeChange) {
onBeforeChange(view, false, options);
}
@ -101,8 +103,7 @@ import 'css!components/viewManager/viewContainer';
$.mobile.activePage = view;
}
resolve(view);
});
return view;
});
}
}