manakai DOM Node Extensions

manakai DOM Node Extensions

[1] manakai DOM Extensions > Extensions to existing interfaces > Extensions to the Node interface

[31] The description for the ElementTypeDefinition and AttributeDefinition interfaces includes the interaction of existing attributes and methods of Node interface and these new node types.

New node types

[23] Two constants are added to the definition group NodeType:

New element type accessors

[9] The manakaiLocalName attribute contains the real local name of the Node.

The type of this attribute is DOMString. This attribute is read-only.

The getter of this attribute MUST return the same value as the localName on the same Node, except when the localName getter is so defined that it must return the canonicalized version of real local name, in that case the real local name MUST be returned.

[81005] Since it has clarified that localName always returns the original local name of the element, use of the manakaiLocalName attribute is discouraged.

[5] The manakaiExpandedURI attribute contans the expanded URI, i.e. the concatenation of the namespace URI and the local name of the Node.

The type of this attribute is DOMString. This attribute is read-only.

  1. If the manakaiLocalName of the Node is null, then the getter MUST return null.
  2. Otherwise, if the namespaceURI of the Node is null, then the getter MUST return the manakaiLocalName of the Node.
  3. Otherwise, the getter MUST return the concatenation of the namespaceURI and then manakaiLocalName.

New tree accessor and mutator

[4] The manakaiParentElement attribute contains the parent element of the Node, if any.

The type of this attribute is Element. This attribute is read-only.

  1. If the parentNode of the Node is null, then the getter MUST return null.
  2. Otherwise, if the parentNode of the Node is an Element, then the getter MUST return that Element.
  3. Otherwise, the getter MUST return the manakaiParentElement of the parentNode of the Node. It might be null.
ISSUE: Should the owner element be returned for an Attr?

[3] The manakaiAppendText method appends a string at the end of the Node.

partial interface Node {
  Node manakaiAppendText(DOMString s);
  void manakaiAppendContent((Node or DOMString) node);
};
[81011] In DOM Perl Binding, s can be a reference to the string.
It was the original intention that for the DOM Perl binding the .= operator is to be overloaded by this method. However, since overloading that operator by this method makes the Perl implementation (at least Perl 5.8.1 and 5.8.7 on GNU/Linux system) unstable, that feature is temporarily disabled.

[81012] When invoked, the method MUST run the following steps with the argument s:

  1. If setting the textContent attribute of the context object has no effect, return the context object and abort these steps.
  2. If setting the textContent attribute would append a Text node as the children of the context object,
    1. If the last child of the context object, if any, is a Text node, replace data with node the Text node, offset length attribute value of the Text node, count 0, and data s.
    2. Otherwise, if the length of s is greater than zero (0), create a Text node whose data is s and insert the node into the context object before null.
  3. Otherwise, if the context object is an instance of the CharacterData interface, replace data with node the context object, offset length attribute value of the context object, count 0, and data s.
  4. Otherwise, set the textContent attribute value to the textContent attribute value immediately followed by s.
  5. Return the context object.

[81013] The manakaiAppendContent method MUST run the following steps:

  1. Let node be the argument.
  2. Let context be the template content of the context object if the context object is an HTML template element, or the context object otherwise.
  3. If node is a [CODE(DOMi)en[Node]], act as if the appendChild method of the Node interface is invoked with the context object context and the argument node.
  4. Otherwise, act as if the manakaiAppendText method of the Node interface is invoked with the context object context and the argument node.

[81014] The method returns nothing.

Read-only flag accessors

[1] The manakaiReadOnly attribute represents whether the Node is read-only or not. This is a boolean attribute. This attribute is read-only.

The getter MUST return true if the Node is read-only. Otherwise, it MUST return false.

[2] The manakaiSetReadOnly method is used to set the manakaiReadOnly attribute. This method has two parameters: newValue and deep. This method returns nothing.

newValue, type boolean, represents the new value of the manakaiReadOnly attribute.

deep, type boolean. represents whether the descendants' manakaiReadOnly attributes should also be set or not.

When invoked, the method MUST set the manakaiReadOnly attribute, i.e. the read-only flag, of the Node to newValue.

If the deep parameter is set to true, then the method MUST act as if the method is also invoked to any of the following Nodes with same newValue and deep parameters:

Metadata accessor

[81008]

partial interface Node {
  attribute DOMString manakaiLanguage;
  attribute DOMString manakaiHTMLLanguage;
};

[6] The manakaiLanguage attribute contans the language information of the Node, if available.

The type of this attribute is DOMString. This attribute is read-write.

This getter MUST act as if the following algorithm is performed:

  1. If the Node is an Element:
    1. If there is an Attr, in the attributes list of the Element, whose namespaceURI is http://www.w3.org/XML/1998/namespace and localName is lang, then the getter returns the value of the Attr.
    2. Otherwise, if there is an Attr, in the attributes list of the Element, whose namespaceURI is null and localName is xml:lang, then the getter returns the value of the Attr.
  2. If the Node has a non-null parentNode, then the getter returns the manakaiLanguage of that Node.
  3. Otherwise, if the Node has a non-null ownerDocument, then the getter returns the manakaiLanguage of that Node.
  4. Otherwise, if the Node is a Document and any natural language information is attached to the Document, for example by Content-Language HTTP header field, then the getter returns it.
    • If such information has different syntax and / or semantics than one for the xml:lang attributes as defined in XML 1.0 and 1.1 specifications, then the getter MUST return an XML-compatible string that is considered as equivalent to that information.
    • If such convertion if not possible, then the getter MUST NOT return any string in this step.
    • If more than one languages are specified, then the string mul MAY be used.
  5. Otherwise, return an empty string.

TODO: Maybe we should clarify what convertion must be done for Documents.

The setter MUST act as if the following algorithm is performed:

  1. Let s as the new value given to the attribute.
  2. If the Node is an Element:
    1. If the Node has one or two Attrs whose namespaceURI is http://www.w3.org/XML/1998/namespace and localName is lang or whose namespaceURI is null and localName is xml:lang, then:
      1. If the Element is read-only, then throw a NO_MODIFICATION_ALLOWED_ERR exceoption and abort the algorithm.
      2. Otherwise, any such Attr MUST be removed from the Element as if removeAttributeNode is invoked with appropriate parameter.
        • Note that a default attribute might appear after the remove operation.
    2. Otherwise, if the element has an Attr whose namespaceURI is http://www.w3.org/XML/1998/namespace and localName is lang:
      1. If the Attr is read-only, then throw a NO_MODIFICATION_ALLOWED_ERR exceoption and abort the algorithm.
      2. Otherwise, set its value to s and set its specified to true.
    3. Otherwise, if the element has an Attr whose namespaceURI is null and localName is xml:lang:
      1. If the Attr is read-only, then throw a NO_MODIFICATION_ALLOWED_ERR exceoption and abort the algorithm.
      2. Otherwise, set its value to s and set its specified to true.
    4. Otherwise, invoke the setAttributeNS method on the Element with parameters http://www.w3.org/XML/1998/namespace, xml:lang, and s.
      • Note that this might cause an exception is thrown.
  3. Otherwise, setter do nothing.

TODO: Setter for Document.
TODO: mutation event consideration

[81009] On getting, the manakaiHTMLLanguage attribute of the Node object MUST return the language of the node HTML.

[81010] On setting, the attribute MUST run the following steps:

  1. If the context object is not an element, abort these steps.
  2. If the element has the lang attribute in the XML namespace, set its value to the new value and abort these steps.
  3. If the element is in the HTML namespace, set the lang attribute in no namespace to the new value and abort these steps.
  4. Set the lang attribute in the XML namespace, set its value to the new value and abort these steps.

Interfaces

[32] Node objects MAY implement the NSResolver interface [SelectorsAPI].

Parsing

[81004]

partial interface Node {
  DOMString? manakaiGetChildNamespaceURI(DOMString? tagName);
};

[81003] The manakaiGetChildNamespaceURI method MUST run the following steps:

  1. If the node document of the Node is an HTML document:
    1. Let tagName be tagName converted to ASCII lowercase.
    2. If the Node is a MathML text integration point:
      1. If tagName is mglyph or malignmark, return the MathML namespace and abort these steps.
      2. Otherwise, jump to the step named HTML.
    3. Otherwise, if the Node is an annotation-xml element in the MathML namespace and tagName is svg, return the SVG namespace and abort these steps.
    4. Otherwise, if the Node is an HTML integration point, jump to the step named HTML.
    5. Otherwise, if the namespaceURI of the Node is the SVG namespace or the MathML namespace, return the namespaceURI and abort these steps.
    6. HTML: If tagName is svg, return the SVG namespace and abort these steps.
    7. Otherwise, if tagName is math, return the MathML namespace and abort these steps.
    8. Otherwise, return the HTML namespace and abort these steps.
  2. Otherwise:
    1. If tagName contains a U+003A COLON character (:):
      1. Let prefix be tagName.
      2. Delete the U+003A COLON character (:) character and any folloing characters from prefix.
      3. Return the result of running locate a namespace <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#locate-a-namespace> for the Node using prefix and abort these steps. Please note that prefix could be the empty string, which is different from null.
    2. Otherise, return the result of running locate a namespace <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#locate-a-namespace> for the Node using null as prefix and abort these steps.

RootNode

[81006]

partial interface DocumentFragment {
  HTMLCollection getElementsByTagName(DOMString localName);
  HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
  HTMLCollection getElementsByClassName(DOMString classNames);
};

[81007] Methods getElementsByTagName, getElementsByTagNameNS, and getElementsByClassName of the DocumentFragment interface MUST' behave in the same way as the methods with same names on the Document interface, respectively.