Bug 523538: don't try to sync to prefs if a <setting> has no pref attribute defined, r=mfinkle
authorGavin Sharp <gavin@gavinsharp.com>
Mon, 09 Nov 2009 09:02:36 -0500
changeset 1076 02ca916759198d2c24d71e7e432da6c995eea33d
parent 1075 befb5bade9e2989d0b28afa40f2a24b4bcab98d9
child 1077 e50511b5e4a1538f87bacaa4d9ab107071f048c3
push id946
push usergsharp@mozilla.com
push dateMon, 09 Nov 2009 14:02:13 +0000
reviewersmfinkle
bugs523538
Bug 523538: don't try to sync to prefs if a <setting> has no pref attribute defined, r=mfinkle
chrome/content/bindings/setting.xml
--- a/chrome/content/bindings/setting.xml
+++ b/chrome/content/bindings/setting.xml
@@ -46,23 +46,23 @@
     <content orient="vertical">
       <xul:label class="settings-title" xbl:inherits="value=label" crop="end" flex="1"/>
       <children />
     </content>
   </binding>
 
   <binding id="setting-base">
     <implementation>
-      <constructor>
+      <constructor><![CDATA[
         let prefValue = this.pref.valueFromPreferences;
         if (prefValue != null) {
           this.pref._setValue(prefValue, false);
           this.prefChanged();
         }
-      </constructor>
+      ]]></constructor>
 
       <method name="fireEvent">
         <parameter name="eventName"/>
         <parameter name="funcStr"/>
         <body>
           <![CDATA[
             let body = funcStr || this.getAttribute(eventName);
             if (!body)
@@ -93,18 +93,25 @@
       <method name="prefChanged">
         <body>
           this.value = this.pref.value;
           this.fireEvent("onsyncfrompreference");
         </body>
       </method>
 
       <property name="value" onget="return this.input.value;" onset="return this.input.value = val;"/>
+      <property name="pref" readonly="true">
+        <getter><![CDATA[
+          // The pref element is only useful if we have a pref attribute
+          return this.hasAttribute("pref") ? this._pref : {};
+        ]]></getter>
+      </property>
+      <field name="_pref">document.getAnonymousElementByAttribute(this, "anonid", "pref");</field>
+
       <field name="type">this.getAttribute("type");</field>
-      <field name="pref">document.getAnonymousElementByAttribute(this, "anonid", "pref");</field>
       <field name="input">document.getAnonymousElementByAttribute(this, "anonid", "input");</field>
     </implementation>
   </binding>
 
   <binding id="setting-bool" extends="chrome://browser/content/bindings/setting.xml#setting-base">
     <content>
       <xul:box flex="1" class="prefbox">
         <xul:vbox flex="1">