12 |
$$self->{local_name}) = @_; |
$$self->{local_name}) = @_; |
13 |
Scalar::Util::weaken ($$self->{owner_element}); |
Scalar::Util::weaken ($$self->{owner_element}); |
14 |
$$self->{child_nodes} = []; |
$$self->{child_nodes} = []; |
15 |
|
$$self->{specified} = 1; |
16 |
return $self; |
return $self; |
17 |
} # ____new |
} # ____new |
18 |
|
|
33 |
} |
} |
34 |
}; |
}; |
35 |
goto &{ $AUTOLOAD }; |
goto &{ $AUTOLOAD }; |
|
} elsif ({ |
|
|
## Read-write attributes (DOMString, trivial accessors) |
|
|
}->{$method_name}) { |
|
|
no strict 'refs'; |
|
|
eval qq{ |
|
|
sub $method_name (\$;\$) { |
|
|
if (\@_ > 1) { |
|
|
if (\${\$_[0]}->{manakai_read_only}) { |
|
|
report Message::DOM::DOMException |
|
|
-object => \$_[0], |
|
|
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
|
|
-subtype => 'READ_ONLY_NODE_ERR'; |
|
|
} |
|
|
if (defined \$_[1]) { |
|
|
\${\$_[0]}->{$method_name} = ''.\$_[1]; |
|
|
} else { |
|
|
delete \${\$_[0]}->{$method_name}; |
|
|
} |
|
|
} |
|
|
return \${\$_[0]}->{$method_name}; |
|
|
} |
|
|
}; |
|
|
goto &{ $AUTOLOAD }; |
|
36 |
} else { |
} else { |
37 |
require Carp; |
require Carp; |
38 |
Carp::croak (qq<Can't locate method "$AUTOLOAD">); |
Carp::croak (qq<Can't locate method "$AUTOLOAD">); |
40 |
} # AUTOLOAD |
} # AUTOLOAD |
41 |
sub owner_element ($); |
sub owner_element ($); |
42 |
|
|
43 |
## The |Node| interface - attribute |
## |Node| attributes |
44 |
|
|
45 |
|
sub base_uri ($) { |
46 |
|
my $self = $_[0]; |
47 |
|
local $Error::Depth = $Error::Depth + 1; |
48 |
|
my $oe = $self->owner_element; |
49 |
|
if ($oe) { |
50 |
|
my $ln = $self->local_name; |
51 |
|
my $nsuri = $self->namespace_uri; |
52 |
|
if (($ln eq 'base' and |
53 |
|
defined $nsuri and $nsuri eq 'http://www.w3.org/XML/1998/namespace') or |
54 |
|
($ln eq 'xml:base' and not defined $nsuri)) { |
55 |
|
my $oep = $oe->parent_node; |
56 |
|
if ($oep) { |
57 |
|
return $oep->base_uri; |
58 |
|
} else { |
59 |
|
return $self->owner_document->base_uri; |
60 |
|
} |
61 |
|
} else { |
62 |
|
return $oe->base_uri; |
63 |
|
} |
64 |
|
} else { |
65 |
|
return $self->owner_document->base_uri; |
66 |
|
} |
67 |
|
} # base_uri |
68 |
|
|
69 |
sub local_name ($) { |
sub local_name ($) { |
70 |
## TODO: HTML5 |
## TODO: HTML5 |
72 |
} # local_name |
} # local_name |
73 |
|
|
74 |
sub manakai_local_name ($) { |
sub manakai_local_name ($) { |
75 |
return ${+shift}->{local_name}; |
return ${$_[0]}->{local_name}; |
76 |
} # manakai_local_name |
} # manakai_local_name |
77 |
|
|
78 |
sub namespace_uri ($); |
sub namespace_uri ($); |
98 |
## NOTE: Same as |Element|'s |prefix|. |
## NOTE: Same as |Element|'s |prefix|. |
99 |
|
|
100 |
if (@_ > 1) { |
if (@_ > 1) { |
101 |
if (${$_[0]}->{manakai_read_only}) { |
if (${${$_[0]}->{owner_document}}->{strict_error_checking} and |
102 |
|
${$_[0]}->{manakai_read_only}) { |
103 |
report Message::DOM::DOMException |
report Message::DOM::DOMException |
104 |
-object => $_[0], |
-object => $_[0], |
105 |
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
114 |
return ${$_[0]}->{prefix}; |
return ${$_[0]}->{prefix}; |
115 |
} # prefix |
} # prefix |
116 |
|
|
117 |
## The |Attr| interface - attribute |
## |Attr| attributes |
118 |
|
|
119 |
|
sub manakai_attribute_type ($;$) { |
120 |
|
my $self = $_[0]; |
121 |
|
if (@_ > 1) { |
122 |
|
if (${$$self->{owner_document}}->{strict_error_checking}) { |
123 |
|
if ($$self->{manakai_read_only}) { |
124 |
|
report Message::DOM::DOMException |
125 |
|
-object => $self, |
126 |
|
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
127 |
|
-subtype => 'READ_ONLY_NODE_ERR'; |
128 |
|
} |
129 |
|
} |
130 |
|
if ($_[1]) { |
131 |
|
$$self->{manakai_attribute_type} = 0+$_[1]; |
132 |
|
} else { |
133 |
|
delete $$self->{manakai_attribute_type}; |
134 |
|
} |
135 |
|
} |
136 |
|
|
137 |
|
return $$self->{manakai_attribute_type} || 0; |
138 |
|
} # manakai_attribute_type |
139 |
|
|
140 |
## TODO: HTML5 case stuff? |
## TODO: HTML5 case stuff? |
141 |
sub name ($) { |
sub name ($) { |
147 |
} |
} |
148 |
} # name |
} # name |
149 |
|
|
150 |
sub value ($;$) { |
sub specified ($;$) { |
151 |
if (@_ > 1) { |
if (@_ > 1) { |
152 |
${$_[0]}->{value} = $_[1]; |
## NOTE: A manakai extension. |
153 |
|
if (${${$_[0]}->{owner_document}}->{strict_error_checking} and |
154 |
|
${$_[0]}->{manakai_read_only}) { |
155 |
|
report Message::DOM::DOMException |
156 |
|
-object => $_[0], |
157 |
|
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
158 |
|
-subtype => 'READ_ONLY_NODE_ERR'; |
159 |
|
} |
160 |
|
if ($_[1] or not defined ${$_[0]}->{owner_element}) { |
161 |
|
${$_[0]}->{specified} = 1; |
162 |
|
} else { |
163 |
|
delete ${$_[0]}->{specified}; |
164 |
|
} |
165 |
} |
} |
166 |
return ${$_[0]}->{value}; |
return ${$_[0]}->{specified}; |
167 |
|
} # specified |
168 |
|
|
169 |
|
sub value ($;$) { |
170 |
|
## TODO: |
171 |
|
shift->text_content (@_); |
172 |
} # value |
} # value |
173 |
|
|
174 |
package Message::IF::Attr; |
package Message::IF::Attr; |