Fix infite loop when getting descendant text content of a label ...

... containing an input

Nishit, could you patch this in and see whether it fixes the problems you're seeing?

We don't have great test coverage for text content calculation so I'd prefer to try this out in a few places before we merge it in to make sure it's not going to break other things.