Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

User property of a <form> element is not enumerable

1 view
Skip to first unread message

Jan Odvarko

unread,
Oct 22, 2009, 6:51:30 AM10/22/09
to
If I create a <form> element and set a new property on it, it's not
visible when enumerating properties. See the following example:

var form= document.createElement('form');
form.myProp = {ID:'test', Value:'someValue'};

// Following cycle doesn't see the "myProp" property
for (var p in form) {
// ...
}

// Anyway, the property is correctly accessible.
alert(form.myProp);

If I create a <div> instead of a <form> it works as expected.

What is special with forms?

Honza

Boris Zbarsky

unread,
Oct 22, 2009, 4:40:44 PM10/22/09
to
On 10/22/09 6:51 AM, Jan Odvarko wrote:
> What is special with forms?

<form id="f">
<input name="foo">
</form>

document.getElementById("f").foo is the <input>.

More to the point, forms have an enumerate hook which effectively
enumerates form.elements in order, as far as I can tell. I wonder
whether this is needed for web compat...

-Boris

Jan Odvarko

unread,
Oct 23, 2009, 4:36:13 AM10/23/09
to
> document.getElementById("f").foo is the <input>.
> More to the point, forms have an enumerate hook which effectively
> enumerates form.elements in order, as far as I can tell.
I see

> I wonder
> whether this is needed for web compat...

Is there any different way how to enumerate these custom properties
(to bypass the form-hook somehow)?

A bug is reported in Firebug see,
http://code.google.com/p/fbug/issues/detail?id=642

To summarize, the DOM panel doesn't show all properties of form
elements.

Honza

Boris Zbarsky

unread,
Oct 23, 2009, 11:23:33 AM10/23/09
to
On 10/23/09 4:36 AM, Jan Odvarko wrote:
>> I wonder
>> whether this is needed for web compat...
> Is there any different way how to enumerate these custom properties
> (to bypass the form-hook somehow)?

I suspect "no" given the current implementation, but check with .js-engine?

-Boris

0 new messages