Consolidate innerHTML setting logic

See https://github.com/facebook/react/commit/7eb33ef#commitcomment-5447724.