Verified Commit d9e4eb88 authored by Camil Staps's avatar Camil Staps 🚀

Add closeWindowOnClose member to Component to allow navigation

parent 20d90352
......@@ -48,6 +48,7 @@ class Component {
this.message_queue=[];
this.shared_clean_values=null;
this.do_debug=false;
this.closeWindowOnClose=true;
this.response_handlers=new Map();
this.request_id=0;
......@@ -93,7 +94,7 @@ class Component {
this.abc.interpret (this.response_handlers.get (data.id),[data.val]);
break;
case 'close':
if (typeof window!='undefined')
if (this.closeWindowOnClose && typeof window!='undefined')
window.close();
break;
default:
......@@ -199,6 +200,8 @@ function connect (_opts) {
return Component.instantiate (opts).then (component => {
if (typeof window!='undefined'){
const onbeforeunload=ev => {
if (!component.closeWindowOnClose)
return;
component.tearDown();
ev.preventDefault();
ev.returnValue='';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment