I'm having trouble understanding a specific step used to solve the integral below, where instead of replacing $g(x)$ by $u$, it is replaced by a function of $u$: $tan(u)$
$$\int sin(x)\sqrt{1+cos^2(x)}dx$$ The following substitution is used: $$cos(x) = tan(u)$$ $$\mathbf{-sin(x)dx = sec^2(u) du}$$ Resulting in the standard integral which can be solved : $$\int sec^2(U)\sqrt{1+tan^2(u)}du = \int sec^2(u) \sqrt{sec^2(u)} = \int sec^3(u) du $$
The substition in boldface is the one I am having trouble understanding. The left part is the same as usual, i.e. $\frac{du}{dx}dx = du$, yet it is set equal to the derivative of $tan(u)$. I understand this is due to replacing $cos(x)$ by $tan(u)$ instead of $u$, but I am having trouble understanding the exact steps. An explanation or name of the method would be greatly appreciated.