iPhones are actually able to detect this and will give a pop-up saying moisture has been detected in the charging port and charging has been disabled out of safety concerns. It even shows you a bypass button for emergencies!
I get a similar notification when I take Apple Watch surfing. Also took an iPhone 11 in a waterproof bag around my neck for pics, but it was a hassle to zip up the wetsuit, and the bag fogged up.