none
[Bug] Bing Maps Web Control Promise implementation is unfriendly to other thenables. RRS feed

  • Question

  • Here's a transcript of a console session showing the following:

    1) instantiating jQuery in the window context.

    2) creating a resolved jQuery deferred ($.when() functioning similar to Promise.resolve() in this case) and sending it to a native Promise.  The native Promise treats the jQuery deferred as a "thenable" and resolves to its value.

    3) Loading Bing API in the window context, which overwrites the native Promise object.

    4) Trying to do the same thing again with the Bing Promise API around the jQuery deferred.  In this case the deferred is not recognized as a thenable so the resolved value of the Promise is the deferred object itself.

    I should expect that in any Promise implementation, resolving any object which duck types as thenable should treat it as a thenable, rather than a plain object, wait for its resolution or rejection, and resolve or reject to its value, respectively.  Because I have no control over Bing APIs taking over the Promise object (that I am aware of, at least), the Promise implementation must conform to this expectation to avoid unexpected behaviors that vary before vs. after the API is loaded.

    Transcript of Bing vs native Promise implementations' treatment of jQuery deferreds.


    Tuesday, May 31, 2016 11:11 PM

Answers

  • The team has looked into this and have created a fix. This is now in the experimental branch of V8. You can test this by adding "&branch=experimental" to the map script URL in your app. This will be merged into the release branch at the end of July.

    [Blog] [twitter] [LinkedIn]

    Wednesday, July 6, 2016 11:53 PM

All replies

  • I'll have the team take a look at this. Out of curiosity, have you tried loading the Bing Maps script before the jQuery script to see if that works for you?

    [Blog] [twitter] [LinkedIn]

    Thursday, June 2, 2016 7:06 PM
  • The team has looked into this and have created a fix. This is now in the experimental branch of V8. You can test this by adding "&branch=experimental" to the map script URL in your app. This will be merged into the release branch at the end of July.

    [Blog] [twitter] [LinkedIn]

    Wednesday, July 6, 2016 11:53 PM