Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Methods can be invoked on non-mapster supported/initialized elements #351

Open
techfg opened this issue Jan 24, 2021 · 0 comments
Open

Methods can be invoked on non-mapster supported/initialized elements #351

techfg opened this issue Jan 24, 2021 · 0 comments
Labels
Milestone

Comments

@techfg
Copy link
Collaborator

techfg commented Jan 24, 2021

Describe the bug
ImageMapster currently has sporadic behavior when invoking a method on an element. For example:

  1. Methods can be called on elements that are not yet been initialized - In some cases, the method returns without error (e.g. select) and in some cases there is an error (e.g., keys) but the error is not meaningful (e.g. Uncaught Can't access data until binding complete.).
  2. Methods can be called on unsupported elements (e.g. div)

To Reproduce
Steps to reproduce the behavior:

  1. Open tooltips example
  2. Execute $('.navmenu').mapster('select') in console
  3. Method completes successfully even though div is not a valid target and mapster cannot be applied to it
  4. Execute $('.navmenu').mapster('keys') in console
  5. Method encounters Uncaught Can't access data until binding complete. exception even though div is not a valid target and mapster cannot be applied to it.
  6. Add the following HTML to the example page
    <img
      id="testimage"
      src="images/beatles_basic.jpg"
      usemap="#beatles-map"
    />
  1. Execute $('#testimage').mapster('select')
  2. Method completes successfully even though mapster is not initialized
  3. Execute $('#testimage').mapster('keys') in console
  4. Method encounters Uncaught Can't access data until binding complete. which is misleading because mapster is not even initialized

Expected behavior
Mapster should only support img/area elements, track initialization and provide meaningful error messages based on situation. Additionally, mapster creates internal elements and there is code in-place that "ignore" these elements during method execution - this additional processing overhead can be avoided by ensuring that mapster is only called on "valid" (user created img/area & initialized) elements.

Screenshots
N/A

Desktop (please complete the following information):
N/A

Smartphone (please complete the following information):
N/A

Additional context
While technically a bug, fixing this properly would result in a breaking change for existing code that uses IM that doesn't follow standard jQuery usage guidelines (wrt to selectors) so it should be saved for next major release and marked as a breaking change.

@techfg techfg changed the title Methods can be invoked on non-mapster elements Methods can be invoked on non-mapster supported/initialized elements Jan 24, 2021
@techfg techfg added this to the 2.0.0 milestone Jan 25, 2021
@techfg techfg added the bug label Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant