From: Matěj Cepl on
Dne 18.12.2009 20:46, Thomas 'PointedEars' Lahn napsal(a):
> So, IIUC, if
> you want to use this code with an MIT-licensed product you will need to
> rewrite it from scratch.

OK, I will. Thanks.

Matěj
--
http://www.ceplovi.cz/matej/, Jabber: mcepl<at>ceplovi.cz
GPG Finger: 89EF 4BC6 288A BF43 1BAB 25C3 E09F EF25 D964 84AC

If Patrick Henry thought that taxation without representation was
bad, he should see how bad it is with representation.
From: Thomas 'PointedEars' Lahn on
David Mark wrote:

> Thomas 'PointedEars' Lahn wrote:
>> David Mark wrote:
>> > Thomas 'PointedEars' Lahn wrote:
>> >> David Mark wrote:
>> >> > Thomas 'PointedEars' Lahn wrote:
>> >> >> /*
>> >> >> * Elements with the same name create a NodeList object,
>> >> >> * however options of select objects are also indexable in Gecko.
>> >> >> */
>> >> >> if (typeof e[0] != "undefined" && typeof e.options == "undefined")
>> >> >
>> >> > I don't care for that.
>> >> You should. If the second `typeof' test would be omitted, execution
>> >> would enter the loop with a SELECT element in a Gecko-based UA.
>> > I understand why, but don't like the way you did it.
>> How would you do it, then?
>
> How would I tell whether it was a SELECT element? The tagName I
> imagine. Also, you might want to try this out:-

So we have something that is by definition a form control object to be
detected either by a RegExp match against its `tagName' property, or a type
test against its `options' property, whereas it is exactly that property
that later needed to determine its value(s). Yes, I do very much prefer the
latter over the former.

> var elForm = document.createElement('form');
> elForm.appendChild(document.createElement('fieldset'));
> window.alert(elForm.elements[0]);

ACK, that displays "[object HTMLFieldSetElement]" in Iceweasel 3.5.6, so
another exclusion must be added to or before serializeControl() to avoid
"undefined=undefined" in the serialization, or worse.

It is of no further concern, though, as child form controls are still
represented as items of the `elements' collection of the form object:

var elForm = document.createElement('form');
var elFSet = document.createElement('fieldset');
elForm.appendChild(elFSet);
elFSet.appendChild(document.createElement("input"));
window.alert(Array.prototype.slice.call(elForm.elements, 0));

(That yields "[object HTMLFieldSetElement],[object HTMLInputElement]" in the
same runtime environment.)

> ...and looking closer, I don't see how your logic will work at all
> with respect to NodeLists:-
>
> var e = es[i];
>
> What makes you think that will result in a NodeList (under any
> circumstance?)

Look even closer. `es' is a reference to the form object's `elements'
collection, which makes `e' a reference to an element object or a NodeList
implementation, and `e[0]', if `e' refers to a NodeList implementation, the
first element of that NodeList.


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann