[LON-CAPA-cvs] cvs: loncom /homework edit.pm

albertel lon-capa-cvs-allow@mail.lon-capa.org
Mon, 10 Sep 2007 23:00:06 -0000


albertel		Mon Sep 10 19:00:06 2007 EDT

  Modified files:              
    /loncom/homework	edit.pm 
  Log:
  - fixes to tag attribute editing wasn't properly handling deletions and 
    insertions of new tag attributes, new values now go to the end, and 
    seetings to '' are removed from the tag
  
  
Index: loncom/homework/edit.pm
diff -u loncom/homework/edit.pm:1.110 loncom/homework/edit.pm:1.111
--- loncom/homework/edit.pm:1.110	Thu Sep  6 20:39:21 2007
+++ loncom/homework/edit.pm	Mon Sep 10 19:00:05 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # edit mode helpers
 #
-# $Id: edit.pm,v 1.110 2007/09/07 00:39:21 albertel Exp $
+# $Id: edit.pm,v 1.111 2007/09/10 23:00:05 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -672,6 +672,10 @@
 		$token->[2]->{$arg}=$newvalue;
 	    }
 	    $rebuild=1;
+	    # add new attributes to the of the attribute seq
+	    if (!grep { $arg eq $_ } (@{ $token->[3] })) {
+		push(@{ $token->[3] },$arg);
+	    }
 	} elsif (!defined($newvalue) && defined($value)) {
 	    delete($token->[2]->{$arg});
 	    $rebuild=1;
@@ -688,6 +692,7 @@
 	$result = '<'.$token->[1];
 	foreach my $attribute (@{ $token->[3] }) {
 	    my $value = $token->[2]{$attribute};
+	    next if ($value eq '');
 	    $value =~s/^\s+|\s+$//g;
 	    $value =~s/\"//g;
 	    &Apache::lonxml::debug("setting :$attribute: to  :$value:");