[Mono-dev] vo.getAttribute is not a function (WebUIValidation*.js bug)
joel reed
joel.reed at ddiworld.com
Wed Jan 3 09:41:33 EST 2007
The following patch fixes a bug in the web validation js files:
class/System.Web/resources/WebUIValidation.js
class/System.Web/resources/WebUIValidation_2.0.js
The "bug" is more like a quality of implementation issue. Basically, the
patch changes all occurrences of
"for (var v in myArray)"
to
"for (var v=0; v < myArray.length; v++)"
Without this change, aspx pages using prototype.js
(http://prototype.conio.net/), a popular ajax javascript library, will
fail with a "vo.getAttribute is not a function" javascript error on
mono. On Microsoft's .Net, they work just fine.
I have attached a sample html file and a copy of prototype.js which
demonstrate why this happens. prototype.js extends the array class (see
http://www.sergiopereira.com/articles/prototype.js.html#Reference.Array),
which causes "for (var v in myArray)" to loop over not just the DOM
elements with validation functions, but also the extended functions of
the Array.prototype. This leads to the "vo.getAttribute is not a
function" javascript error, when the loop tries to call getAttribute on
the "each" function.
To fix this problem, I switched to the syntax "for (var v=0; v <
myArray.length; v++)", which doesn't loop over the extended function set.
To reiterate: the ASPX pages which originally surfaced this issue work
on Microsoft's .Net platform, but not on mono. With the attached patch,
the ASPX pages work on mono.
OK to apply?
jr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vo.GetAttribute.patch
Type: text/x-patch
Size: 4495 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070103/ec81a8e0/attachment.bin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070103/ec81a8e0/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: prototype.js
Type: application/javascript
Size: 55149 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070103/ec81a8e0/attachment-0001.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: joel.reed.vcf
Type: text/x-vcard
Size: 405 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070103/ec81a8e0/attachment.vcf
More information about the Mono-devel-list
mailing list