Find the domain of the functions of the type $f(x)^{g(x)}$. Find the domain of $(\frac{2+x}{1-x})^{\frac{1}{x}}$

I tried to find the domain of this function but could not find.Then i referred the symbolab.com domain calculator,and it showed me a technique to find the domain of the functions of the type $f(x)^{g(x)}$.It found out the doamin as $[-2,0)\cup(0,1)$
It says for finding the domain of the functions of the type $f(x)^{g(x)}$,The condition is $f(x)\geq0$
The reason it gave was
$\sqrt{f(x)}=f(x)^{\frac{1}{2}}$(or any even root) has real values only when $f(x)\geq 0$
Therefore a function of the form $f(x)^{g(x)}$ is only defined for $f(x)\geq 0$ since $g(x)$ may take values like $\frac{1}{2},\frac{3}{4}...$.
I am confused here because i think $g(x)$ may take values like $\frac{1}{3},\frac{1}{7}...$ also in which $f(x)<0$ is also allowed.
But the domain it gave was correct because i verified from the graphing calculator desmos.com.But i am confused why it took only $f(x)\geq 0$ and not $<0$ 
Please help me clarify this confusion or please suggest me some other method to find the domain of the functions of the type $f(x)^{g(x)}$. 
 A: Consider first, $\frac{2+x}{1-x}$. Then for this quantity to be negative $x<-2$ and $x>1$, so there is no intersection. Hence this is always positive. So $(\frac{2+x}{1-x})^{\frac1x}$ is always positive $\forall x$. Clearly $x\neq 1$.
Now consider $h(x)=(\frac{2+x}{1-x})^{\frac1x}$. Taking log both sides (why is this justified ? ) we get
$ln\ h(x)= \frac1x\ ln(\frac{2+x}{1-x})$. Now for this equation to hold we must have $x\neq 0$ and $(\frac{2+x}{1-x})>0$. So either both $2+x$ and $1-x$ are positive or both of them are negative. Analysinf the corresponding cases gives $x\in [-2,0)\cup(0,1)$.
A: for non-elementary reasons there is no unique way to define non-integral powers of negative numbers as there are finitely (if the power is rational) and infinitely (if the power is irrational) many choices and they are all complex (non-real) numbers unless the exponent is integral and they all coincide and are real so there is a unique such, while there is a standard way (like the usual plus square root say) to define any real power of a positive number (zero is special and has only positive powers obviously), though there are again more such powers (finite in the rational case, infinite in the non-rational case) if the exponent is not integral, but there is a unique positive one which is taken as standard
so in general when you do f(x)^g(x), you need f(x) positive, g arbitrary but defined, or f(x)=0, g(x) positive, or f(x) negative, g(x) integer
in your case note that 1/x integral makes f(x) positive, so +/- 1/3 and the like work because f(1/3) is positive, not because the exponent is integral
