fix a TypeError when relatedTarget isnt defined