Add multiple attr in d3 at once

How to add multiple attributes in d3 v5 like this

svg.attr({
   width: w, 
  height: h
});

this method may works in v3.

I don’t think this has changed since v3.