The following proof is from 'Two Proofs of the Existence and Uniqueness of the Partial Fraction Decomposition', page 4.
Lemma 2.1. Let $h(x), g(x) \in R[x]$ (real polynomials), $k$ a positive integer, and $r \in \mathbb R$ such that $g(r) \neq 0$. If $A_1,...,A_k \in \mathbb R$ such that $h(x)(x-r)^k+A_1g(x)(x-r)^{k-1}+A_2g(x)(x-r)^{k-2}+$ $...+A_kg(x)=0$, then $A_1=A_2=...=A_k=0$.
Proof: If we evaluate $h(x)(x-r)^k+A_1g(x)(x-r)^{k-1}+A_2g(x)(x-r)^{k-2}+...+A_kg(x)=0$ at $x=r$, we get $h(x)(0)^k+A_1g(x)(0)^{k-1}+A_2g(x)(0)^{k-2}+...+A_kg(x)=0$. So that $A_kg(r)=0$. However, $g(r) \neq 0$ therefore, $A_k=0$.
Now our equation reads $h(x)(x-r)^k+A_1g(x)(x-r)^{k-1}+...+A_{k-1}g(x)(x-r)=0$. Factoring out and canceling $x-r$, gives us $h(x)(x-r)^{k-1}+A_1g(x)(x-r)^{k-2}+...+A_{k-1}g(x)$ $=0$.
Therefore, applying the same argument again we find that $A_{k-1}=0$. Continuing in this fashion we find that $A_1=A_2=...=A_k=0$.
My question is whether it is legal to repeatedly factor and cancel $(x-r)$ and at each step evaluate the resulting polynomial at $x=r$. Doesn't the domain of the resulting polynomial exclude $x = r$?
Alternatively I have looked at this post for a different proof but I am not sure how to apply the given answers to prove the above lemma.