Jim Crow laws never mentioned race, yet the courts found they had a "sham secular purpose" and really did target race. For example they would say things like you could only vote if your grandfather owned property. No mention of race but mostly blacks failed to qualify.it is constitutional because the actual text does not mention race or religion but geographical locations.
The courts can and do look behind the stated surface intention to see if the law actually targets race or religion.
And this is exactly what the 4th and 9th circuits did in this case, they looked at the campaign statements used to justify the law and found that it was intended to reduce Muslim immigration.