The short answer
In good riads and reputable restaurants, yes: salads are generally washed in treated water and prepared with care. At very basic street stalls, raw vegetables rinsed in uncertain water carry a little more risk. If your stomach is sensitive, eat cooked salads and hot dishes for the first few days, and peel your own fruit.
In more detail
Moroccan salads come in two kinds, and the difference matters. Cooked salads, such as zaalouk made from aubergine and taktouka made from peppers and tomato, are cooked down and served at room temperature. They carry little more risk than any other cooked dish. Raw salads of tomato, onion and cucumber are the ones to think about, because they are only as clean as the water they were rinsed in.
At a riad or a busy restaurant, the kitchen uses treated water and prepares food hygienically. At the most basic stalls, you cannot see how the vegetables were washed. That is where a cautious traveller skips the raw plate and orders something hot from the grill.
With children, the advice is firmer: stick to bottled water and cooked food, and skip unpeeled raw salads and salads rinsed in tap water. Riads and visitor restaurants will happily serve plain cooked options.
None of this means missing out. The cooked salads that open a Moroccan meal are among the best things on the table, and fruit you peel yourself, such as oranges and bananas, is always a safe choice.
