emit event on appended element on dom

Start working on #4747,

I'm wondering if we shouldn't have the `this['append_'+type](json[type],
md, element)` return (a reference to) the inner element it happends to
pass it to the event.

I'm also wondering if I should pass the mimetype as a parameter of the
event, or dynamically create the event-name based on the mime-type.

Last possibility is that each of the `append_xxx(xxx, md, element)`
(except JS) seem to end with `element.append(toinsert)` we could hve
them return the `toinsert` and move `element.append(toinsert)` to `append
mimetype.`

Thoughts ?