<script> function buttonClicked(event) { var button = event.target; alert("left attribute of " + button.id + " is of type " + typeof(button.left) + " and has value " + button.left); } </script>
Thanks for the response. I would be helpful to update the doc then and warn people about this: if you do foo.left += 10, you will have a surprise... (actually I had one...).
On 2 Nov 2006 11:16:05 -0800, ramaboule <julien.bo...@gmail.com> wrote:
> Hi Neil,
> Thanks for the response. I would be helpful to update the doc then and > warn people about this: if you do foo.left += 10, you will have a > surprise... (actually I had one...).
Please feel free to update the doc yourself. The documentation is in the wiki, letting anyone edit it.
Now that I'm given this responsability, I'm chickening out a little bit...
The thing is that you could (maybe should) read the documentation as just an XML reference and in this case, the current documentation makes perfect sense: if you had to write a schema for this attribute, you would say: <xs:attribute name="left" type="xs:integer"/>
There are a lot of attributes in this case: top, flex etc... I haven't checked the "boolean" ones but I will ASAP.
What I find confusing is that the mapping of these attributes in the javascript DOM objects is string as opposed to a type similar to the XML one.
So a better approach I think would be just to add a comment for all these integer attributes saying something like: WARNING: XUL attributes are exposed to javascript as string objects. If you're doing any computation on these, please make sure to use the parseInt function.
Nickolay Ponomarev wrote: > On 2 Nov 2006 11:16:05 -0800, ramaboule <julien.bo...@gmail.com> wrote: > > Hi Neil,
> > Thanks for the response. I would be helpful to update the doc then and > > warn people about this: if you do foo.left += 10, you will have a > > surprise... (actually I had one...).
> Please feel free to update the doc yourself. The documentation is in > the wiki, letting anyone edit it.
ramaboule wrote: > So a better approach I think would be just to add a comment for all > these integer attributes saying something like: > WARNING: XUL attributes are exposed to javascript as string objects. If > you're doing any computation on these, please make sure to use the > parseInt function.
This behaviour will probably change in the future though, such that values are properly exposed as integers when needed.
ramaboule wrote: >Thanks for the response. I would be helpful to update the doc then and warn people about this: if you do foo.left += 10, you will have a surprise... (actually I had one...).
On 2 Nov 2006 18:30:58 -0800, ramaboule <julien.bo...@gmail.com> wrote:
> The thing is that you could (maybe should) read the documentation as > just an XML reference and in this case, the current documentation makes > perfect sense: if you had to write a schema for this attribute, you > would say: > <xs:attribute name="left" type="xs:integer"/>
You're right about the attributes, which are always strings. From JS you usually work with properties (e.g. |elem.left|) , which are different from attributes.
In any case, claiming that 'type' of something is an integer, when it's in fact a string representation of an integer, is confusing. I'm not sure how this should be fixed myself. Maybe put "string containing an integer" in the type field or something?
> What I find confusing is that the mapping of these attributes in the > javascript DOM objects is string as opposed to a type similar to the > XML one.
Yep, as Neil said, it's unfortunate and probably will be fixed later.
> So a better approach I think would be just to add a comment for all > these integer attributes saying something like: > WARNING: XUL attributes are exposed to javascript as string objects. If > you're doing any computation on these, please make sure to use the > parseInt function.
If you add this to individual pages, it won't be seen by people reading the XUL:(element) pages.
> Nickolay Ponomarev wrote: > > On 2 Nov 2006 11:16:05 -0800, ramaboule <julien.bo...@gmail.com> wrote: > > > Hi Neil,
> > > Thanks for the response. I would be helpful to update the doc then and > > > warn people about this: if you do foo.left += 10, you will have a > > > surprise... (actually I had one...).
> > Please feel free to update the doc yourself. The documentation is in > > the wiki, letting anyone edit it.
Hm. Yeah, we need to do something about this. Probably exactly that way, by changing the type to "string containing an integer" or possibly adding a note to each page indicating that the integers are represented in strings.
Eric Shepherd Developer Documentation Lead she...@mozilla.com
On Nov 3, 2006, at 6:23 AM, Nickolay Ponomarev wrote:
> In any case, claiming that 'type' of something is an integer, when > it's in fact a string representation of an integer, is confusing. I'm > not sure how this should be fixed myself. Maybe put "string containing > an integer" in the type field or something?
> I've also checked that the boolean attributes are exported correctly > to javascript (into boolean properties and not "string representing a > boolean").
Thanks for that. Note, however, that *all* attributes are strings (while _properties_ can be of varying types). Right now the XUL_element_attributes page looks like some _attributes_ are strings, while some are booleans, which is confusing.
> On 11/3/06, Julien Boeuf <julien.bo...@gmail.com> wrote: > > Very cool. I'll do it this week-end and send you links to the modified > > pages to make sure you're ok with the changes.
> > Julien.
> > On 11/3/06, Eric Shepherd <esheph...@mozilla.com> wrote: > > > The more help we get, the better. :)
> > > Eric Shepherd > > > Developer Documentation Lead > > > she...@mozilla.com
> > > On Nov 3, 2006, at 1:23 PM, Julien Boeuf wrote:
> > > > That sounds good to me too. Eric, do you want me to help or do you > > > > prefer to do it yourself?
> I've also checked that the boolean attributes are exported correctly > to javascript (into boolean properties and not "string representing a > boolean").
> Thanks,
> Julien.
> On 11/3/06, Julien Boeuf <julien.bo...@gmail.com> wrote: >> Very cool. I'll do it this week-end and send you links to the >> modified >> pages to make sure you're ok with the changes.
>> Julien.
>> On 11/3/06, Eric Shepherd <esheph...@mozilla.com> wrote: >> > The more help we get, the better. :)
>> > Eric Shepherd >> > Developer Documentation Lead >> > she...@mozilla.com
>> > On Nov 3, 2006, at 1:23 PM, Julien Boeuf wrote:
>> > > That sounds good to me too. Eric, do you want me to help or do >> you >> > > prefer to do it yourself?