getter function for bounds object

One difference between passing your bounds as a D3 rect selection
versus an associative array is that the former responds to the common
D3 convention of calling attr() as a getter function to retrieve a
property, while the latter would only respond properly to calling the
property directly as in bounds.x. This adds a very lightweight getter
function, also called attr(), to bounds objects that are passed in as
associative arrays so as to blur the lines a bit and make this respond
as though it’s cooperating with the D3 native conventions. In other
words, now your bounds will behave as desired if you hard-code them and
then try to run bounds.attr(‘width’).

And yeah, all this complex boundary handling logic may be a bit over
the top, I don’t know. I’m unsure as to whether this is the best
approach, but for now it seems wise to code in the additional
robustness.