fix dispatchEvent bug introduced by be454688