Countries are buying US gov't debt because: 1) they have a lot of USD due to exporting goods to the US and 2) it's one of the safest places you can park money.
Sure, it would be bad if they dumped treasuries (at a big loss), but why would they do that if they put the money there in the first place because it was safe?