@@ [1] This is the work-in-progress specification for the manakai's DOM binding for Perl. This specification only scopes [[manakai]]'s DOM implementation; it does not try to define what any other DOM implementation should do. However, other DOM implementation that exposes interfaces to Perl scripts '''[[MAY]]''' use this binding. @@ [2] TODO: - Truck the draft for the ECMAScript binding authored by W3C Web APIs WG - Write comparison with SVGT 1.2's DOM Perl Language Binding - The global object ([CODE(DOMi)@en[[[Window]]]]) * Objects and interfaces [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 [CODE@en[bless]]ed in a Perl class, unless otherwise specified. The Perl class '''[[MUST]]''' implement the DOM interfaces implemented by the DOM object. @@ better wording, getFeature consideration * Methods and attributes [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. ;; Note that specifying [CODE(perl)@en[[[undef]]]] as the argument to the [[Perl]] method, which set the [CODE(DOM)@en[[[null]]]] value to the [[DOM]] attribute, is different from specifying no argument, which returns the [[DOM]] attribute value. [8] A [[DOM]] parameter to a method is [DFN@en[optional]] if either [CODE(DOM)@en[[[null]]]] or [CODE(IDL)@en[[[boolean]]]] [CODE(DOM)@en[[[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 [CODE(perl)@en[[[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. * Constants * Exceptions and errors [9] Throwing an exception [['''MUST''']] be implemented by [[Perl]] [CODE(perl)@en[[[die]]]] function. If the exception is one defined in DOM specification, the argument to the [CODE(perl)@en[[[die]]]] function [['''MUST''']] be an object implementing the associated exception interface. ;; Implementations are encouraged to employ the [CODE(perl)@en[[[Error]]]] module as a basis to construct their own exception mechanism. @@ Exception classes @@ DOMErrors * Events * Naming Rule * Data types [10] In this section, [DFN@en[number type]]s includes: [CODE(IDL)@en[[[long]]]], [CODE(IDL)@en[[[unsigned long]]]], [CODE(IDL)@en[[[unsigned long long]]]], [CODE(IDL)@en[[[short]]]], and [CODE(IDL)@en[[[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., [CODE(perl)@en[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., [CODE(perl)@en[0+]] operation). @@ Similary, IDL type is expected to be evaluated in the Boolean context. IDL type is corresponding to any scalar valu\ e in Perl. IDL type is bound to object. The value is bound to . ** [CODE(DOM)@en[DOMString]] @@ The type is bound to Perl string value and expected to be evaluated in the string context. A value 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 be interpreted as a ISO/IEC 8859-1 string\ . ** [CODE(DOM)@en[DOMTimeStamp]] [4] '''[CODE(DOM)@en[DOMTimeStamp]] for a Calendar Date-Time''' A [CODE(DOM)@en[DOMTimeStamp]] value that is an absolute date-time [['''MUST''']] be represented by a scalar value of the number of the seconds from [CODE[[[1970-01-01T00:00:00Z]]]]. The scalar value [['''MAY''']] contain fraction part, which represents a fraction of a second. ;; For example, [CODE[[[1970-01-01T00:00:00Z]]]] is mapped to a numeric value of [CODE(perl)[[[0]]]]. @@ Leap seconds, days before [CODE[[[1970-01-01T00:00:00Z]]]] * Security * Features and DOMImplementationRegistry * memo