Let $X$ and $Y$ be Hausdorff topological spaces, and let $f : X \to Y$ be a Borel-measurable function. Suppose that $D \subseteq X$ is dense, that the image $f(D) \subseteq Y$ is dense, and that $f$ is a homeomorphism from $D$ to $f(D)$.

Does it follow that $f$ is a homeomorphism from $X$ to $Y$? 

If not, is $f$ a measurable isomorphism from $X$ to $Y$?