emberjs / ember.js

Ember.js - A JavaScript framework for creating ambitious web applications
https://emberjs.com
MIT License
22.47k stars 4.21k forks source link

Google's DFP gpt.js (Google's Ad Server) file doesn't work anymore #16646

Closed bogdanteodoru closed 6 years ago

bogdanteodoru commented 6 years ago

Hi,

So apparently Google changed something in their DFP gpt.js library and it seems it doesn't work with Ember anymore when trying to load gpt.js programmatically (please read further).

So, if the gpt.js file is loaded into the index.html file, before all vendor.js/app.js files that Ember uses to load/start the application, everything works great (ads are shown, the application runs smoothly).

If you want to load that file programmatically (via Ajax load, or via document.createElement, etc), something that apparently was modified in Google's gpt.js conflicts with something from Embers String extension. To be more specific:

ember-runtime/ext/string
/**
See [Ember.String.w](/api/classes/Ember.String.html#method_w).
@method w
@for String
@private
*/
StringPrototype.w = function () {
return _emberRuntimeSystemString.w(this);
};

For whatever reason, the String.prototype.w method is conflicting with a w() method from Google's gpt.js file and an error is trown.

Our current fix was to disable the String extension done by ember in the ENV file using https://emberjs.com/api/ember/2.8/namespaces/Ember.String (EmberENV.EXTEND_PROTOTYPES.String = false).

gpt.js - https://www.googletagservices.com/tag/js/gpt.js

locks commented 6 years ago

I am closing as you seem to have arrived at the correct solution, and we have demonstrated the intent of deprecating Ember.String prototype extensions in RFC 236. Thank you for reporting!