rewrite element generation in merge to be idiomatic
rewrite element generation in merge to be idiomatic

I'm leaving the loop that generates result names separate from this
because that code is dependent on `selection` and generates elements
itself, which may be confusing when reading the code and trying to debug
it.

seliopou/d3-filters