fix: ensure initialization completes on subsequent attempts #428
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
IMPORTANT
What is this change for?
Description (required)
The underlying issue is actually a regression from 0aca845 way back in October 2011. In that commit, there was an change in approach to how deferred methods were executed. Prior to the commit, when the situation arose were initialization was called but something else was "in-flight",
bind
(the equivalent of initialization) was added to the command processing queue. However, in the change, Lines 2165 thru 2172,img.bind
was put in its place which would actually call the jquery.bind method (aka. jquery.on) to register an event listener. The changes in this commit are the root cause of why this bug currently exists.Since the above commit, the code was calling
jquery.bind
with no parameters which actually does nothing and even with parameters, would not have been an equivalent replacement in functionality to the previousqueue_command
that was called.In 48125a6, the img.unbind was fixed to properly queue an
unbind
command, however the img.bind was not updated/fixed.In this commit,
bind
was changed toon
sincebind
was deprecated in jQuery 3.Finally, in this commit,
on
was removed entirely since it does not do anything to begin with (see above).In short, the change made in 0aca845 was incorrect and it should have queued a
bind/initialization
when map data is already present. This ensures that the unbind called just prior completes fully before mapster is reinitialized.This PR corrects the issue and ensures mapster is successfully initialized even on multiple initialization calls.
Test plan (required)
Closing issues
Closes #427