China avoided getting attacked like the USSR because of the USSR. The US was focused on it and China was viewed as a useful tool to split communists and harm the USSR. The sino-soviet split helped China survive at the expense of the USSR.
After the fall of the USSR it was Deng's reforms that continued to keep China alive. The capitalists thought they would end China in the longterm and they couldn't resist the vast wealth they could make from investing into this growth market of 1billion+ people. This incentive continues to be the reason China is not simply isolated on trade, there are thousands of capitalists making too much money from China and they do not support going against China as it would hurt their income.