comparison 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
comparison
equal deleted inserted replaced
108:c6fb6964de4c 109:ddf0f037d460
8 our $AUTOLOAD; 8 our $AUTOLOAD;
9 sub AUTOLOAD { 9 sub AUTOLOAD {
10 my $this = shift; 10 my $this = shift;
11 my ($method) = ($AUTOLOAD =~ /(\w+)$/); 11 my ($method) = ($AUTOLOAD =~ /(\w+)$/);
12 12
13 my @result = $this->selectNodes($method); 13 return if $method eq 'DESTROY';
14 14
15 return $result[0] if @result; 15 if ($method =~ /^add(\w+)/) {
16 return; 16 my ($name,$args) = @_;
17 return $this->appendChild($this->document->CreateControl($name,$1,$args));
18 }
19
20 if ( @_ >= 1 ) {
21 # set
22 # we can't assing a node, so this is a dynamic property
23 return $this->nodeProperty($method,@_);
24 } else {
25 # get
26 # try a dynamic property first
27 if ( my $val = $this->nodeProperty($method) ) {
28 return $val;
29 } else {
30 # and return a first child node as last opportunity
31 my @result = $this->selectNodes($method);
32
33 return $result[0] if @result;
34 return;
35 }
36 }
37 die new IMPL::Exception("We shoud never get here, this is a bug!!!");
17 } 38 }
18 39
19 sub as_list { 40 sub as_list {
20 $_[0]->childNodes; 41 $_[0]->childNodes;
21 } 42 }