[Bug 27887] New: "Mutation method macro" should handle empty nodes

https://www.w3.org/Bugs/Public/show_bug.cgi?id=27887

            Bug ID: 27887
           Summary: "Mutation method macro" should handle empty nodes
           Product: WebAppsWG
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DOM
          Assignee: annevk@annevk.nl
          Reporter: jsbell@google.com
        QA Contact: public-webapps-bugzilla@w3.org
                CC: mike@w3.org, www-dom@w3.org

https://dom.spec.whatwg.org/#mutation-method-macro (as of rev b7563aa)

Given one of the operations that references it, e.g.:

void prepend((Node or DOMString)... nodes);

Per Web IDL, the variadic argument can be omitted entirely, so e.g.
myDiv.prepend() should not throw (unless specified to in prose).

The various operations don't specify special handling when called with no
arguments. They execute the mutation method macro, which has:

1. Let /node/ be null.
2. Replace each string in /nodes/ with a Text node whose data is the string
value.
3. If /nodes/ contains more than one node, set /node/ to a new DocumentFragment
and append each node in /nodes/ to it. Rethrow any exceptions.
Otherwise, set /node/ to the single node /nodes/ contains.

Step 3 doesn't appear to handle the case if /nodes/ contains zero nodes. It's
not more than one, but yet not a single node.

Proposed fix:

Replace "contains more than one node" with "contains exactly one node".

This would result in an empty DocumentFragment, which turns most of the
ParentNode/ChildNode operations into no-ops when called with no argument except
`replaceWith` which acts like `remove`.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Received on Friday, 23 January 2015 19:18:17 UTC