Subject: | bug when CODE in HASH |
Date: | Wed, 17 Jan 2007 14:52:37 +0200 |
To: | bug-Data-JavaScript-Anon [...] rt.cpan.org |
From: | Sergey Borodich <bor [...] univ.kiev.ua> |
When found CODE in HASH
module generate broken javascript code
perl code:
$VAR1 = {
'constraint_methods' => {
'phone' => sub { "DUMMY" },
'last_name' => sub { "DUMMY" },
'email' => sub { "DUMMY" },
'first_name' => sub { "DUMMY" }
},
'required' => [
'login',
'password',
'password2',
'email',
'first_name',
'last_name',
};
generated code:
var signup_form = { constraint_methods: { phone: , last_name: , email: ,
first_name: }, required: [ "login", ...
but code like "phone: ," is broken
$errstr:
CODE was found in the dump struct. Data::JavaScript::Anon only supports
objects based on, or references to SCALAR, ARRAY and HASH type variables.
problem near line 90
anon_dump don't check for undef return from recursive himself call
I suggest return "" (empty string) here
like
diff /usr/lib/perl5/vendor_perl/5.8.8/Data/JavaScript/Anon.pm.orig
/usr/lib/perl5/vendor_perl/5.8.8/Data/JavaScript/Anon.pm
90c90
< . $class->anon_dump(
$something->{$_}, $processed )
---
Show quoted text
> . ($class->anon_dump(
$something->{$_}, $processed ) || '""')
OR
check for undef return and not add this key to javascript code never
--
Sergey Borodich
http://bor.org.ua