[gnome-shell/wip/rstrode/rhel-7.9: 45/86] endSessionDialog: squash "reference to undefined property" warning




commit 85290eb68ecfea591e0707a01b02557acbc241f1
Author: Will Thompson <will willthompson co uk>
Date:   Tue Sep 25 18:01:36 2018 +0100

    endSessionDialog: squash "reference to undefined property" warning
    
    dialogContent is set to one of the elements of the list DialogContent,
    but not all of those have a checkBoxText property. When logging out (as
    opposed to shutting down), this causes a warning:
    
        JS WARNING: [resource:///org/gnome/shell/ui/endSessionDialog.js
        763]: reference to undefined property "checkBoxText"
    
    (The line number corresponds to this line in 3.28.3.)
    
    The warning is apparently not triggered if the undefined property is
    used as part of a boolean expression:
    
        gjs> var x = {};
        gjs> x.a;
        typein:2:1 strict warning: reference to undefined property "a"
        gjs> if (x.b) { log('oh no'); }
        gjs> x.c || ''
        ""
    _setCheckBoxLabel() just checks the truthiness of its 'text' argument,
    and the empty string is false-y, so passing '' rather than undefined has
    no functional effect.

 js/ui/endSessionDialog.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/js/ui/endSessionDialog.js b/js/ui/endSessionDialog.js
index 7d18d0b790..07c954139b 100644
--- a/js/ui/endSessionDialog.js
+++ b/js/ui/endSessionDialog.js
@@ -760,7 +760,7 @@ var EndSessionDialog = new Lang.Class({
         let updatePrepared = this._pkOfflineProxy.UpdatePrepared;
         let updatesAllowed = this._updatesPermission && this._updatesPermission.allowed;
 
-        _setCheckBoxLabel(this._checkBox, dialogContent.checkBoxText);
+        _setCheckBoxLabel(this._checkBox, dialogContent.checkBoxText || '');
         this._checkBox.actor.visible = (dialogContent.checkBoxText && updatePrepared && updatesAllowed);
         this._checkBox.actor.checked = (updatePrepared && updateTriggered);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]