Fix sorting issue for tokens input with remote autocompletion
If tokens input is configured to use remote autocompletion or
forced to use it due to $wgPageFormsMaxLocalAutocompleteValues limits
the event data on select2:select event does not contain a link
to the actual select option element, thus the "sorting fix" which
ensures elements stay in the order they were added is unable
to work correctly.
This patch fixes this by checking presence of the link at
evt.params.data.element and fetching related element from DOM
if necessary.
Change-Id: I6613633d2bdee3aa3902bd95159650a73ba41694