211 |
return ''; |
return ''; |
212 |
} # manakai_language |
} # manakai_language |
213 |
|
|
214 |
|
## TODO: document |
215 |
|
sub manakai_html_language ($;$) { |
216 |
|
my $self = $_[0]; |
217 |
|
local $Error::Depth = $Error::Depth + 1; |
218 |
|
|
219 |
|
if (@_ > 1) { |
220 |
|
if ($self->node_type == 1) { # ELEMENT_NODE |
221 |
|
if (defined $_[1]) { |
222 |
|
## TODO: non HTML |
223 |
|
if ($self->has_attribute_ns (undef, 'xml:lang')) { |
224 |
|
$self->set_attribute_ns (undef, [undef, 'xml:lang'] => $_[1]); |
225 |
|
# or exception |
226 |
|
} else { |
227 |
|
$self->set_attribute (lang => $_[1]); |
228 |
|
} |
229 |
|
} else { |
230 |
|
## TODO: html lang |
231 |
|
$self->remove_attribute_ns |
232 |
|
(q<http://www.w3.org/XML/1998/namespace>, 'lang'); |
233 |
|
$self->remove_attribute_ns (undef, 'xml:lang'); |
234 |
|
} |
235 |
|
} |
236 |
|
|
237 |
|
return undef unless defined wantarray; |
238 |
|
} |
239 |
|
|
240 |
|
my $target = $self; |
241 |
|
while (defined $target) { |
242 |
|
if ($target->node_type == 1) { # ELEMENT_NODE |
243 |
|
|
244 |
|
## TODO: non-html |
245 |
|
my $r = $target->get_attribute ('lang'); |
246 |
|
return $r if defined $r; |
247 |
|
|
248 |
|
## Step 1 |
249 |
|
|
250 |
|
## Step 1.1 |
251 |
|
$r = $target->get_attribute_ns |
252 |
|
(q<http://www.w3.org/XML/1998/namespace>, 'lang'); |
253 |
|
return $r if defined $r; |
254 |
|
|
255 |
|
## Step 1.2 |
256 |
|
$r = $target->get_attribute_ns (undef, 'xml:lang'); |
257 |
|
return $r if defined $r; |
258 |
|
} |
259 |
|
|
260 |
|
## Step 2 |
261 |
|
$target = $target->parent_node; |
262 |
|
} |
263 |
|
|
264 |
|
## Step 3 |
265 |
|
my $od = $self->owner_document; |
266 |
|
if (defined $od) { |
267 |
|
return $od->manakai_language; |
268 |
|
} |
269 |
|
|
270 |
|
## Step 4 |
271 |
|
## TODO: from upper-level protocol, if $self isa Document |
272 |
|
|
273 |
|
## Step 5 |
274 |
|
return ''; |
275 |
|
} # manakai_html_language |
276 |
|
|
277 |
sub last_child ($) { |
sub last_child ($) { |
278 |
my $self = shift; |
my $self = shift; |
279 |
return $$self->{child_nodes} && $$self->{child_nodes}->[0] |
return $$self->{child_nodes} && $$self->{child_nodes}->[0] |