check for all necessary conditions at initialization

Rather than checking in disjointed places whether the selection is
empty or the boundaries are provided as an input argument or D3 is
defined or whatever else, let’s just check for everything at
initialization. If anything is missing we will just return the original
selection and exit the function, otherwise we know it’s safe to proceed
with the rest.