new DOM4 insertions methods and return values

The older DOM mutation methods like

Node appendChild(Node node);

returned the node you inserted

The newer DOM mutation methods like

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

return void instead.

It would be useful if append returned either the single node or a
DocumentFragment

use-case is

```js
var style = document.head.append(
  document.createElement("style"))

style.type = "text/css"
style.textContent = "..."
```

It's simply less verbose for the common case for the new insertion methods
to return the node they operated on.

In the case you pass multiple nodes it should do the same as
`document.appendChild(someDocumentFragment)` does which is return the
document fragment you passed in (even though it's empty).

I've also written and maintain polyfills for those mutation methods and
have just landed a commit to return the values (
https://github.com/Raynos/insert/commit/3c823876bbac99638c56bc27ab043481587357c6
)
because the void return type was annoying.

Received on Wednesday, 16 January 2013 01:52:34 UTC