[Jifty-commit] r4716 - in jifty/branches/jquery: . lib/Jifty/Web/Form

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Mon Dec 17 00:37:57 EST 2007


Author: gugod
Date: Mon Dec 17 00:37:55 2007
New Revision: 4716

Modified:
   jifty/branches/jquery/   (props changed)
   jifty/branches/jquery/lib/Jifty/Web/Form/Field.pm
   jifty/branches/jquery/lib/Jifty/Web/Menu.pm

Log:
 r8526 at GOP (orig r4708):  jesse | 2007-12-17 04:50:56 +0800
 
 * Revert mistaken commit. 
 * Fix menus to properly weaken "parent" relationships (and normalize _parent and parent)
 


Modified: jifty/branches/jquery/lib/Jifty/Web/Form/Field.pm
==============================================================================
--- jifty/branches/jquery/lib/Jifty/Web/Form/Field.pm	(original)
+++ jifty/branches/jquery/lib/Jifty/Web/Form/Field.pm	Mon Dec 17 00:37:55 2007
@@ -298,12 +298,15 @@
 
 sub action {
     my $self   = shift;
-    my $action = $self->_action(@_);
-
+    if (my $action = shift @_) {
     # If we're setting the action, we need to weaken
     # the reference to not get caught in a loop
-    Scalar::Util::weaken( $self->{_action} ) if @_;
-    return $action;
+        Scalar::Util::weaken($action);
+        return $self->_action($action);
+    }
+
+    return $self->_action();
+
 }
 
 =head2 current_value

Modified: jifty/branches/jquery/lib/Jifty/Web/Menu.pm
==============================================================================
--- jifty/branches/jquery/lib/Jifty/Web/Menu.pm	(original)
+++ jifty/branches/jquery/lib/Jifty/Web/Menu.pm	Mon Dec 17 00:37:55 2007
@@ -2,9 +2,9 @@
 
 use base qw/Class::Accessor::Fast/;
 use URI;
-use Scalar::Util ();
+use Scalar::Util qw(weaken);
 
-__PACKAGE__->mk_accessors(qw(label parent sort_order link target escape_label class));
+__PACKAGE__->mk_accessors(qw(label _parent sort_order link target escape_label class));
 
 =head1 NAME
 
@@ -23,8 +23,15 @@
 
 sub new {
     my $package = shift;
+    my $args = ref($_[0]) eq 'HASH' ? shift @_ : {@_};
+
+    
+
+    $args->{'_parent'} ||= delete $args->{'parent'};
+    weaken $args->{'_parent'} if $args->{'_parent'};
+
     # Class::Accessor only wants a hashref;
-    $package->SUPER::new( ref($_[0]) eq 'HASH' ? @_ : {@_} );
+    $package->SUPER::new( $args);
 
 }
 
@@ -35,17 +42,26 @@
 
 =cut
 
-sub label {
-    my $self = shift;
-    $self->{label} = shift if @_;
-    return $self->{label};
-}
-
 =head2 parent [MENU]
 
 Gets or sets the parent L<Jifty::Web::Menu> of this item; this defaults
 to null.
 
+=cut
+
+
+sub parent {
+    my $self = shift;
+    my $parent;
+    if (@_) {
+        $parent = shift;
+        weaken $parent;
+    }
+
+    return $self->_parent($parent);
+}
+
+
 =head2 sort_order [NUMBER]
 
 Gets or sets the sort order of the item, as it will be displayed under


More information about the Jifty-commit mailing list