From 70fbcdaf212679ec4670c9affeb5cf6b59d74bf0 Mon Sep 17 00:00:00 2001 From: "ben%bengoodger.com" Date: Tue, 23 Aug 2005 16:53:08 +0000 Subject: [PATCH] 289361 - checkbox constructor is weird, back out rv1.7 to 1.6, moving common initialization logic for checkboxes and colorpickers into special cases in the preferences XML rather than exposing new apis on checkbox and colorpicker. r=mconnor, a=brendan git-svn-id: svn://10.0.0.236/trunk@178701 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/toolkit/content/widgets/checkbox.xml | 11 +---- .../toolkit/content/widgets/colorpicker.xml | 1 - .../toolkit/content/widgets/preferences.xml | 43 ++++++++++++++++--- 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/mozilla/toolkit/content/widgets/checkbox.xml b/mozilla/toolkit/content/widgets/checkbox.xml index 5fc27c12d72..3133564ca42 100644 --- a/mozilla/toolkit/content/widgets/checkbox.xml +++ b/mozilla/toolkit/content/widgets/checkbox.xml @@ -35,9 +35,9 @@ - - - - // Sync the checked value from the "value" attribute if necessary. - this.checked = this.value; - diff --git a/mozilla/toolkit/content/widgets/colorpicker.xml b/mozilla/toolkit/content/widgets/colorpicker.xml index 551c4eedf1c..7a9451457cc 100644 --- a/mozilla/toolkit/content/widgets/colorpicker.xml +++ b/mozilla/toolkit/content/widgets/colorpicker.xml @@ -451,7 +451,6 @@ - @@ -363,7 +379,24 @@ dump(e); } } - var value = ("value" in aElement) ? aElement.value : aElement.getAttribute("value"); + + /** + * Read the value of an attribute from an element, assuming the + * attribute is a property on the element's node API. If the property + * is not present in the API, then assume its value is contained in + * an attribute, as is the case before a binding has been attached. + */ + function getValue(element, attribute) { + if (attribute in element) + return element[attribute]; + return element.getAttribute(attribute); + } + if (aElement.localName == "checkbox") + var value = getValue(aElement, "checked"); + else if (aElement.localName == "colorpicker") + value = getValue(aElement, "color"); + else + value = getValue(aElement, "value"); switch (this.type) { case "int":