Window)[48] Statements about conformance in this specification
are only applied to implementations that support related
feature. For example, MUST-level requirements
for treatement of the EventHandler objects
do not apply to implementations that do not support
DOM Events module.
[3]
A DOM object, i.e. an object implementing one
or more DOM interfaces, MUST be represented
by a Perl object, i.e. a thingly referenced
by some Perl references and blessed in
a Perl class, unless otherwise specified.
The Perl class MUST implement
the DOM interfaces implemented by the DOM object.
[5] A DOM method MUST be implemented as a Perl method.
[6] A read-only DOM attribute MUST be implemented as a Perl method that returns the value contained in the DOM attribute. The Perl method MAY throw an implementation dependent exception if any argument is specified for the Perl method.
[7] A read-write DOM attribute MUST be implemented as a Perl method. The Perl method MUST return the value contained in the DOM attribute if no argument is specified for the Perl method (i.e. the only argument to the subroutine implementing the Perl method is the object itself). Otherwise, the Perl method MUST try to set the first argument specified for the method (i.e. the second argument to the subroutine implementing the Perl method) to the DOM attribute.
[8]
A DOM parameter to a method is optional if
either null or boolean
false value is allowed to be specified
to that parameter and any following DOM parameter
is optional.
The Perl method MUST act as if an undef
or a Perl false value, depending on the data type of the parameter,
is specified to each optional parameter if no argument
corresponding to that parameter is specified.
[9]
Throwing an exception MUST be implemented by Perl
die function. If the exception is one
defined in DOM specification, the argument to the
die function MUST
be an object implementing the associated exception interface.
Error module as a basis
to construct their own exception mechanism.[15] Names of DOM methods and attributes MUST be mapped to Perl method (subroutine) name by following algorithm:
LOW LINE character,
the lowercase variant of the sequence except the last letter,
a LOW LINE character,
and the lowercase variant of the last letter of the sequence.LOW LINE character
followed by the lowercase variant of the letter.localName
is mapped to local_name,
setAttributeNS to
set_attribute_ns,
createLSInput to
create_ls_input, and
MozBoxSizing to
_moz_box_sizing.[14] Exceptions.
[10] In this section, number types includes:
long, unsigned long,
unsigned long long,
short,
and unsigned short.
[11]
If the return value of the DOM method or the DOM attribute
is of number type and a Perl method return a value
in that type, jt MUST return a value
that can be evaluated as a number (by, e.g., 0+
operation).
[12]
If a DOM method parameter or the DOM attribute is
of number type and it is necessary for a Perl method to
get the specified value, it MAY evaluate
the specified value as a value (by, e.g., 0+
operation).
is expected to be evaluated in the Boolean context.
IDL type <TYPE^^DISCore|QName::idl|any> is corresponding to any scalar valu\
e
in Perl. IDL type <TYPE^^DISCore|QName::idl|Object> is bound to object.null[23]
The null value in DOM is bound to
undef in Perl.
[24]
If something is defined to return or set null,
it MUST return or set undef
unless otherwise specified.
[25]
Where null is allowed to
be specified, an implementation MUST behave as if a
null is specified when
a undef is specified.
[26]
Where null is not allowed to
be specified, how an implementation behaves when
a undef depends on the
expected data type. An implementation MAY
cause zero or more uninitialized
warnings
reported by Perl or MAY report its own
uninitialized
warnings, when warnings
are enabled by e.g. use warnings
pragma.
DOMStringThe <TYPE::MIString> type is bound to Perl string value and expected to be evaluated in the string context. A <TYPE::MIString> value <kwd:MUST> be interpreted as a sequence of characters rather than a sequence of bytes or octets. If it is represented internally as a byte string, i.e. the utf8 flag turned off, it <kwd:MUST> be interpreted as a ISO/IEC 8859-1 <bibref::ISO8859-1> string\ .
[33]
Some methods are defined to accept a scalar reference
specified as a value of a parameter. Such a method,
when a scalar reference is specified as a parameter value,
MUST dereference the parameter value as a
scalar reference (i.e. by operator ${})
before it is in use, if the ref of the parameter
value is SCALAR.
DOMTimeStamp[4] DOMTimeStamp for a Calendar Date-Time
A DOMTimeStamp value that is
an absolute date-time MUST be represented
by a scalar value of the number of the seconds
from 1970-01-01T00:00:00Z.
The scalar value MAY contain fraction part,
which represents a fraction of a second.
1970-01-01T00:00:00Z
is mapped to a numeric value of 0.1970-01-01T00:00:00ZDOMImplementationRegistry[16]
The variable
$Message::DOM::DOMImplementationRegistry
MUST contain a value via which methods
provided by DOMImplementationRegistry
object can be invoked.
$Message::DOM::DOMImplementationRegistry->get_dom_implementation
returns a DOM implementation.
DOMImplementationRegistry
object don't have to be an object in the Perl
context; it might be a string representing
the package name of the class implementing
the DOMImplementationRegistry
interface.[18] Unless otherwise specified,
an object implementing DOM interface
MUST NOT overload an operator
by use overload
in a way that breaks how that operator works
for normal
objects.
"" operator of a class implementing
the Element interface must not
be overloaded so that an object of that class returns the
XML representation of that element.[28] In any way, when an operator is overloaded, it MUST be consistent with other operators.
eq
operator is overloaded,my $eq = $a eq $b; my $ne = $a ne $b; die unless ($eq and not $ne) or (not $eq and $ne);
... must not die.
[17] For following interfaces, dereferencing an object as array acts as if it is an array:
That is,
$obj->[$n]
MUST return the same value as
$obj->item ($n)
if $obj is an object implementing
any of interfaces listed above and $n
is a non-negative integer less than
$obj->length.
DOMConfiguration (as in ECMAScript binding; EXISTS return true iff the parameter name is recognized)[29]
If an array-like or hash-like object is read-only,
STORE, STORESIZE,
DELETE, and any other operations
that implies these operations MUST
throw an NO_MODIFICATION_ALLOWED_ERR
DOMException.
[22]
Several interfaces are defined as function-like.
Only Perl native CODE references, i.e.
values whose ref is CODE,
and objects for which the &{} operation is defined
MUST be treated as if they implement the
function-like interfaces and are referred to as objects
implementing the function-like interfaces. Each function-like interface
has a method, typically named as handleEvent.
Invoking that method on the object implementing a function-like
interface from another language binding invokes the
object itself, by &{} operation. In the Perl binding itself,
however, the method of the interface is not directly accessible on
the object implementing the interface.
handle_event method (and no
&{} operation defined) does not
implement the function-like interfaces.[43] Function-like interfaces are:
[44]
When the method would be invoked, the &{}
operation MUST be performed over the object with appropriate
arguments. The return value of the &{}
operation MUST be treated as if the return value
of the method. If the &{} operation
results in an exception is raised, it MUST
be treated as if it is an exception raised by the method.
$node->add_event_listener ('click', sub {
my $ev = shift;
print $ev->details, "\n";
return 0;
});would make the subroutine invoked when the node is clicked.
The subroutine, implementing the EventHandler
interface and treated as if it is the handleEvent
method, would prints the
number of clicks and then cancel the default action
for the event.
[45] Though in some of function-like interfaces constants are defined,
they are not accessible via the object implemeting that interface
in the Perl binding. Other interface might provide
such constants alternatively. For example,
objects implementing the Node
interface provides contants in UserDataHandler
interface (see >>42).
Node interface[27]
Multiple calles of the getter of
attributes or
childNodes on a Node
MUST return the same object respectively in terms
of Perl eq operator.
my $c1 = $node->child_nodes; my $c2 = $node->child_nodes; die unless $c1 eq $c2;
... must not die.
[34] The manakaiAppendText
method of the Node interface
accepts a scalar reference (>>33) as the first parameter.
[42]
A package that implements the Node
interface MUST implement the OperationType
constant group of the UserDataHandler
interface.
Document interfacecreateElementNS method and the createAttributeNS method[13] If the second parameter, qualifiedName,
is an array reference, i.e. the ref
operator with that parameter returns a string
of ARRAY, then the parameter
MUST be interpreted as following:
undef, then there is
no namespace prefix (i.e. the qualified name has no
COLON character).undef; if it is, then
it MUST be treated as if an empty string
is specified.Using an array reference, an illegal qualified name can be specified. If the qualified name is illegal, then an appropriate exception might be thrown as defined by DOM specifications.
qualifiedName
parameter of the createDocumentType
method of the DOMImplementation
interface has no special interpretation for
an array reference, since the method does not
parse the parameter as a pair of
namespace prefix and local name.createTextNode, createComment, createCDATASection[32] Methods createTextNode,
createComment, and
createCDATASection of the
Document interface
accept a scalar reference (>>33) as the first parameter.
NodeList interface[30]
For any NodeList object,
the == operator MUST
be so overloaded that it returns whether
two arguments are equal in the equality defined
for the isEqualNode method
of the Node interface.
However, if the other operand is not a
NodeList object, then
it MUST return a false value.
NamedNodeMap interface[31]
For any NamedNodeMap object,
the == operator MUST
be so overloaded that it returns whether
two arguments are equal in the equality defined
for the isEqualNode method
of the Node interface.
NSResolver Interface[46]
A Perl CODE reference (or any object
that can be dereferenced as if it were a CODE
reference) can be specified as if it were
an NSResolver interface.
When the lookupNamespaceURI method
of an NSResolver object $obj
is invoked, it MUST be done by the algorithm
(or its equivalents) represented by the following subroutine
where $_[0] is the parameter to the method:
sub {
my $prefix = $_[0];
if (UNIVERSAL::can ($obj, 'lookup_namespace_uri')) {
return $obj->lookup_namespace_uri ($prefix);
} else {
return $obj->($prefix);
}
}undef.[47]
Invoking the lookupNamespaceURI
method on the object implementing the NSResolver
interface from another language binding MUST
behave as if the algorithm above is executed.
Note that in the Perl binding itself, however,
the method of the interface is not directly accessible
on the object implementing the interface when
the object is a CODE reference in fact.
Specifications listed below are only normative for implementations that support features defined by those specification.
[39] >>38 $SourceClass (名無しさん)
(名無しさん)
In binding languages that support setting to a readonly attribute setting media to a string must set the value of mediaText on the MediaList object.
[CSSOM]
(名無しさん)
undefas the argument to the Perl method, which set thenullvalue to the DOM attribute, is different from specifying no argument, which returns the DOM attribute value.