Closed Bug 391534 Opened 13 years ago Closed 12 years ago
<preference> with id='' and name='' has unknown type ''
Summary: preferences ... has unknown type '' → <preference> with id='' and name='' has unknown type ''
The constructor of the preference binding expects that all its attributes are already set. This is the case when the element is created from a <preference> tag in a xul file but it's not the case when it's created with createElement like here: http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/toolkit/content/widgets/preferences.xml&rev=1.74#1074
Assignee: nobody → florian
Status: NEW → ASSIGNED
Attachment #293750 - Flags: review?(mano)
So, why do you attach the binding (i.e. actually *insert* the element to the document) before setting the attributes? Are you sure everything done in this ctor will be set correctly once you do set the name property?
(In reply to comment #2) > So, why do you attach the binding (i.e. actually *insert* the element to the > document) before setting the attributes? I didn't write this code, but I would guess it's to take advantage of the properties of the binding, instead of setting the attributes. Moreover, in this case the code wants to save the value of the <preference> element to the parent window, so getting the value from the pref system first (what the ctor would do) is really not wanted. > Are you sure everything done in this > ctor will be set correctly once you do set the name property? > The constructor adds an observer for the pref (this will be done correctly when setting the name property) and sets the value to the one stored in the preferences (or the one stored in the parent prefwindow if there is one). Anyway, both of these actions will fail if the name property isn't already set. To get in a consistent state without executing the code of the ctor, you would need to set both the name and the value properties. That's what the code linked in comment 1 does.
Comment on attachment 293750 [details] [diff] [review] patch v1 Please rephrase that to something like "If the element has been inserted without the name attribute set", this has nothing to do with the createElement case in particular. r=mano otherwise.
Attachment #293750 - Flags: review?(mano) → review+
Severity: normal → minor
OS: Windows XP → All
Hardware: PC → All
Whiteboard: [has patch, needs review mano]
Comment on attachment 293750 [details] [diff] [review] patch v1 Trivial patch, only prevents a warning from flooding the Error Console.
Attachment #293750 - Flags: approval1.9?
Checking in toolkit/content/widgets/preferences.xml; /cvsroot/mozilla/toolkit/content/widgets/preferences.xml,v <-- preferences.xml new revision: 1.76; previous revision: 1.75 done Checked in with the rephrased comment, as requested in comment 4.
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.