In recent days, we've seen some employers saying they'd refuse to hire people based on those people's praise of the Hamas attack on Israel (or at least certain kinds of praise), see, e.g., this story about one employer [UPDATE: and others] and this statement from another:

(For more on the particular statement that led to the revocation of the offer, see here.) Likewise, one can imagine other employers refusing to hire people based on those people's hypothetical praise of various kinds of Israeli retaliation against the attack. Is that legal, at least for private employers?