fix(notify): make TauriNotification.permission assignable (no-op setter)
The injected notification bridge defined `permission` as a getter-only property. When the notification plugin / a polyfill assigned `Notification.permission`, it threw "Cannot set property permission of function TauriNotification ... which has only a getter" at page load. Add a no-op setter so it still reads 'granted' but assignment can't crash. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -58,7 +58,10 @@ const NOTIFICATION_BRIDGE: &str = r#"(function(){
|
|||||||
TauriNotification.prototype=Object.create(EventTarget.prototype);
|
TauriNotification.prototype=Object.create(EventTarget.prototype);
|
||||||
TauriNotification.prototype.constructor=TauriNotification;
|
TauriNotification.prototype.constructor=TauriNotification;
|
||||||
TauriNotification.prototype.close=function(){};
|
TauriNotification.prototype.close=function(){};
|
||||||
Object.defineProperty(TauriNotification,'permission',{get:function(){return 'granted';},configurable:true});
|
// get-only 'permission' threw "Cannot set property permission ... which has
|
||||||
|
// only a getter" when the notification plugin / a polyfill assigned it. Add a
|
||||||
|
// no-op setter so the value stays 'granted' but assignment can't crash.
|
||||||
|
Object.defineProperty(TauriNotification,'permission',{get:function(){return 'granted';},set:function(){},configurable:true});
|
||||||
TauriNotification.requestPermission=function(){return Promise.resolve('granted');};
|
TauriNotification.requestPermission=function(){return Promise.resolve('granted');};
|
||||||
TauriNotification.maxActions=0;
|
TauriNotification.maxActions=0;
|
||||||
Object.defineProperty(window,'Notification',{value:TauriNotification,writable:true,configurable:true});
|
Object.defineProperty(window,'Notification',{value:TauriNotification,writable:true,configurable:true});
|
||||||
|
|||||||
Reference in New Issue
Block a user