Properly handle unknown self-close tags

For #5822. To @dangoor, not urgent.