clear selection event queue before emitting event

Clear the event queue before the selection event is fired to prevent
recursing if an event handler also triggers a selection event
Add test case for selection event recursion issue
Merge branch 'master' into dev-0.4

Skip d24e623 and 632764f due to conflicts; easier to re-add manually
Selection: Clear selection event queue before emitting event

Clear the event queue before the selection event is fired to prevent
recursing if an event handler also triggers a selection event

h/t @nicknisi for original 0.3 fix.