kimroen / ember-cli-document-title

Adding document title behaviour to your ember app
MIT License
216 stars 61 forks source link

Wrap vendor file in an IIFE #74

Closed paulcwatts closed 3 years ago

paulcwatts commented 6 years ago

This does two things:

  1. Prevents pollution in the global namespace.
  2. Most importantly, it prevents the native window.Promise from being overridden.

The diff is ugly, but none of the code within the IIFE was changed. I promise :)

ming-codes commented 6 years ago

@kimroen This please. Native async functions don't return instances of the global Promise. It'll always returns a native promise, causing the following to fail.

(async function() {})() instanceof Promise // false
paulcwatts commented 6 years ago

@kimroen Any chance of getting this reviewed? If you want I can make the diff look better by not indenting the code.

bummzack commented 6 years ago

Yes please. I get the following Error in IE 11 when using this module:

Error while processing route: index Cannot redefine non-configurable property 'Promise' TypeError: Cannot redefine non-configurable property 'Promise'

To clarify: This error only triggers if you use a module that swaps out Promise, like ember-indexeddb. Both modules work on their own in IE 11, but don't work nicely together.

scalvert commented 5 years ago

We should try to get this merged once #80 is merged.

scalvert commented 5 years ago

Spoke to @kimroen via Twitter. He's on vacation right now, but will look into all PRs once back.

snewcomer commented 3 years ago

1.1.0 is released with this change!