move check outside forEach loop
Merge pull request #658 from remotestorage/bug/656-dispatchEvent_inefficient_looping

Move check outside forEach loop (closes #656)