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

Targeting es5 causing issues when using types derived from EventEmitter #97

Open
joebeernink opened this issue Jun 5, 2021 · 0 comments
Labels
question Further information is requested

Comments

@joebeernink
Copy link

ES5 Targeting in react-azure-maps causes an issue when you try to combine react-azure-maps with the HtmlMapLayer SDK available from Microsoft.
(https://github.com/Azure-Samples/azure-maps-html-marker-layer)

In the Azure Maps SDK EventManager.Invoke method, the code appears as follows:

  public invoke(eventType: string, targetOrArgs: any, args?: any) {
    // If args is undefined assume there is not target for the event.
    if (typeof args === "undefined") {
      // Empty string indicates the map global level.
      this._invokeListeners(eventType, "", targetOrArgs);
    } else {
      if (targetOrArgs instanceof Layer && Layer._isMBoxEvent(eventType)) {
        this._invokeListeners(eventType, targetOrArgs.getId(), args);
      } else if **(targetOrArgs instanceof EventEmitter)** {
        targetOrArgs._invokeEvent(eventType, args);
      } else {
        throw new Error("The invoke target is invalid.");
      }
    }
  }

In the Azure-Maps-Html-Marker-Layer src/extentions/ExtendedHtmlMarker.ts file, the HtmlMarker is extended as follows:
export interface ExtendedHtmlMarker extends azmaps.HtmlMarker {

Unfortunately, this results in the line (targetOrArgs instanceOf EventEmitter) behaving differently in ES5 than it does in ES6.

Under ES6, it behaves correctly, because the ES6 version of JS recognizes a derived class of a derived class of a base class as an instance of the base class... but ES5 instanceOf cannot do this, so in ES5, this check returns false, where in ES6, this returns true.

And since react-azure-maps includes the es5 minified version of the Azure Maps SDK, any app that uses react-azure-maps and wants to also use the HtmlMarkerLayer cannot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants