I was reading my textbook and I came up across the entropy $S(T,V,N)$ where temperature $T$, volume $V$, and number of particles $N$ are the independent variables. According to the chain rule the total differential of the entropy in this case is : $$dS=\left(\frac{\partial S}{\partial T}\right)_{V,N}dT + \left(\frac{\partial S}{\partial V}\right)_{T,N}dV + \left(\frac{\partial S}{\partial N}\right)_{T,V}dN.$$ Then my textbook proceeds to evaluate $\left(\frac{\partial S}{\partial T}\right)_{V,N}$ as $$\left(\frac{\partial S}{\partial T}\right)_{V,N}=\left(\frac{\partial S}{\partial E}\right)_{V,N}\left(\frac{\partial E}{\partial T}\right)_{V,N}$$ and then also inserts the result $\left(\frac{\partial S}{\partial E}\right)_{V,N}=\frac{1}{T}$ from when $E$, $N$, and $V$ are the independent variables not $T$, $N$ and $V$.
Is this mathematically correct/legal?