Fix emit events on 'window' and 'document' objects
(cherry picked from commit 3beccffc21fbcd3e21681fc74a29b0c56a31572f)

Conflicts:

	on.js
	tests/on/on.js