39 |
return shift->{parent_node}; |
return shift->{parent_node}; |
40 |
} # parent_node |
} # parent_node |
41 |
|
|
42 |
|
sub manakai_parent_element ($) { |
43 |
|
my $self = shift; |
44 |
|
my $parent = $self->{parent_node}; |
45 |
|
while (defined $parent) { |
46 |
|
if ($parent->node_type == 1) { |
47 |
|
return $parent; |
48 |
|
} else { |
49 |
|
$parent = $parent->{parent_node}; |
50 |
|
} |
51 |
|
} |
52 |
|
return undef; |
53 |
|
} # manakai_parent_element |
54 |
|
|
55 |
## NOTE: Only applied to Elements and Documents |
## NOTE: Only applied to Elements and Documents |
56 |
sub child_nodes ($) { |
sub child_nodes ($) { |
57 |
return shift->{child_nodes}; |
return shift->{child_nodes}; |
206 |
return 'Whatpm::NanoDOM::DOMImplementation'; |
return 'Whatpm::NanoDOM::DOMImplementation'; |
207 |
} # implementation |
} # implementation |
208 |
|
|
209 |
|
sub document_element ($) { |
210 |
|
my $self = shift; |
211 |
|
for (@{$self->child_nodes}) { |
212 |
|
if ($_->node_type == 1) { |
213 |
|
return $_; |
214 |
|
} |
215 |
|
} |
216 |
|
return undef; |
217 |
|
} # document_element |
218 |
|
|
219 |
package Whatpm::NanoDOM::Element; |
package Whatpm::NanoDOM::Element; |
220 |
push our @ISA, 'Whatpm::NanoDOM::Node'; |
push our @ISA, 'Whatpm::NanoDOM::Node'; |
221 |
|
|
286 |
return shift->{local_name}; |
return shift->{local_name}; |
287 |
} # local_name |
} # local_name |
288 |
|
|
289 |
|
sub manakai_local_name ($) { |
290 |
|
return shift->{local_name}; # no case fixing for HTML5 |
291 |
|
} # manakai_local_name |
292 |
|
|
293 |
sub namespace_uri ($) { |
sub namespace_uri ($) { |
294 |
return shift->{namespace_uri}; |
return shift->{namespace_uri}; |
295 |
} # namespace_uri |
} # namespace_uri |
296 |
|
|
297 |
|
sub manakai_element_type_match ($$$) { |
298 |
|
my ($self, $nsuri, $ln) = @_; |
299 |
|
if (defined $nsuri) { |
300 |
|
if (defined $self->{namespace_uri} and $nsuri eq $self->{namespace_uri}) { |
301 |
|
return ($ln eq $self->{local_name}); |
302 |
|
} else { |
303 |
|
return 0; |
304 |
|
} |
305 |
|
} else { |
306 |
|
if (not defined $self->{namespace_uri}) { |
307 |
|
return ($ln eq $self->{local_name}); |
308 |
|
} else { |
309 |
|
return 0; |
310 |
|
} |
311 |
|
} |
312 |
|
} # manakai_element_type_match |
313 |
|
|
314 |
sub node_type { 1 } |
sub node_type { 1 } |
315 |
|
|
316 |
## TODO: HTML5 capitalization |
## TODO: HTML5 capitalization |