Move the dom/function check up in `baseIsEqual`.