comparison Lib/IMPL/DOM/Node.pm @ 122:a7efb3117295

Fixed bug in IMPL::DOM::Navigator::selectNodes Fixed bug in IMPL::DOM::Node::selectNodes renamed operator 'type' to 'typeof' in IMPL::Object::Abstract A proper implementation of the IMPL::DOM::Node::nodeProperty and a related changes in the IMPL::DOM::Property module, now the last is very simple.
author wizard
date Tue, 08 Jun 2010 20:12:45 +0400
parents 1722ca51537c
children e30bdd040fe3
comparison
equal deleted inserted replaced
121:92c850d0bdb9 122:a7efb3117295
189 return $Axes{$axis}->($this) 189 return $Axes{$axis}->($this)
190 } 190 }
191 191
192 sub selectNodes { 192 sub selectNodes {
193 my $this = shift; 193 my $this = shift;
194 my ($path) = @_; 194 my $path;
195 195
196 $path = ref $path eq 'ARRAY' ? $path : ( @_ == 1 ? $this->translatePath($path) : [@_]); 196 if (@_ == 1) {
197 $path = $this->translatePath($_[0]);
198 } else {
199 $path = [@_];
200 }
197 201
198 my @set = ($this); 202 my @set = ($this);
199 203
200 while (my $query = shift @$path) { 204 while (@$path) {
205 my $query = shift @$path;
201 @set = map $_->selectNodesAxis($query), @set; 206 @set = map $_->selectNodesAxis($query), @set;
202 } 207 }
203 208
204 return wantarray ? @set : \@set; 209 return wantarray ? @set : \@set;
205 } 210 }
339 344
340 sub nodeProperty { 345 sub nodeProperty {
341 my $this = shift; 346 my $this = shift;
342 my $name = shift; 347 my $name = shift;
343 348
349 if (my $method = $this->can($name)) {
350 return &$method($this,@_);
351 }
352
344 if (@_) { 353 if (@_) {
345 # set 354 # set
346 return $this->{$_propertyMap}{$name} = shift; 355 return $this->{$_propertyMap}{$name} = shift;
347 } else { 356 } else {
348 return $this->{$_propertyMap}{$name}; 357 return $this->{$_propertyMap}{$name};
349 } 358 }
359 }
360
361 sub listProperties {
362 my ($this) = @_;
363
364 my %props = map {$_->Name, 1} $this->get_meta(typeof IMPL::Class::PropertyInfo, sub { $_->Attributes->{domProperty}},1);
365
366 return (keys %props,keys %{$this->{$_propertyMap}});
350 } 367 }
351 368
352 sub qname { 369 sub qname {
353 $_[0]->{$nodeName}; 370 $_[0]->{$nodeName};
354 } 371 }