Fixed null reference bug in HTML/JS document parsing