fix #2036: check if the fragment is added

fix #2036: check if the fragment is added