However, you do point out an interesting 'wrinkle', in that electors could/can have always voted for the winner of the national popular vote. In fact, technically, electors could/can have ultimately voted for whomever they preferred. That being said, the ultimate fail safe is simple good faith on behalf of electors. And if that fails, individual state legislators of course have practically unlimited power to enforce decisions.
There's something unique about this case that I haven't fully investigated. The judge is clearly not ruling that state legislative bodies cannot control electors - that of course is entirely false. States are sovereign entities free to act as they please within broad federal constitutional guidelines. (If anyone doubts that, check out sanctuary states.) Rather, the opinion apparently is focused on a specific mechanism that in the judge's opinion fails some type of constitutional test.
The way I read the Constitution, it gives the states authority on who will be the electors, but does not say they can require that elector to vote for a specific candidate. That would invalidate the entire concept of the electoral college. According to Federalist Paper 68, it is intended as a safety mechanism against the selection of an undesirable candidate.