Reminds me of the shortcut that works for the happy path but is utterly fucked by real data. This is an interesting trap, can it easily be avoided without walking the dom?
But I think it's moot, parsing HTML is not very expensive if you don't have to actually render it.