diff Lib/IMPL/Web/TT/Collection.pm @ 109:ddf0f037d460

IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT) Some fixes to the web document model. (beta version)
author wizard
date Mon, 17 May 2010 05:12:08 +0400
parents 0e72ad99eef7
children 4369d5458bb6
line wrap: on
line diff
--- a/Lib/IMPL/Web/TT/Collection.pm	Fri May 14 16:06:06 2010 +0400
+++ b/Lib/IMPL/Web/TT/Collection.pm	Mon May 17 05:12:08 2010 +0400
@@ -10,10 +10,31 @@
 	my $this = shift;
 	my ($method) = ($AUTOLOAD =~ /(\w+)$/);
 	
-	my @result = $this->selectNodes($method);
+	return if $method eq 'DESTROY';
+	
+	if ($method =~ /^add(\w+)/) {
+		my ($name,$args) = @_;
+		return $this->appendChild($this->document->CreateControl($name,$1,$args));
+	}
 	
-	return $result[0] if @result;
-	return;
+	if ( @_ >= 1 ) {
+		# set
+		# we can't assing a node, so this is a dynamic property
+		return $this->nodeProperty($method,@_);
+	} else {
+		# get
+		# try a dynamic property first 
+		if ( my $val = $this->nodeProperty($method) ) {
+			return $val;
+		} else {
+		# and return a first child node as last opportunity
+			my @result = $this->selectNodes($method);
+	
+			return $result[0] if @result;
+			return;
+		}
+	}
+	die new IMPL::Exception("We shoud never get here, this is a bug!!!");
 }
 
 sub as_list {