There is next to no risk in doing that, and once my kids are capable of going to the toilet on their own i.e. in terms of opening the doors, locking the cubicles, reaching the taps, etc. then they'll do just that.
No risk yet 2 children were raped in a maccy d's toilet.
I'm not saying it will happen to every child, but that's less risky than leaving them on their own for a longer period and something horrific happened to them.