Ѓорѓи Ќосев (2013-12-20T16:33:12.000Z)
domenic at domenicdenicola.com (2014-01-03T17:00:59.945Z)
On 12/20/2013 05:13 PM, Kevin Smith wrote: > If you're using modules, you wouldn't need to mess with the global > object. You could just import AssimilatingPromise as "Promise" into > the current module. The local binding would override the global > Promise variable. Here is code that breaks with that solution: ``` function createParser(code) { return {then: chainedTransformation => { ...; return this; } } } waitForFormSubmit() .then(e => $.get(getUrlFromUrlField())) .then(code => createParser(code, options)) ``` 1. If you're just importing AssimilatingPromise, the DOM-interacting function returns a regular Promise and breaks when it gets to the unbranded jQuery `$.get` 2. If you're overriding the global Promise with AssimilatingPromise, it breaks at createParser as the parser gets assimilated (infact it will go into an endless loop)