mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-26 17:46:26 +03:00
6cb12ad174
In our tests, we can load the library many times. Each time, the polyfills get installed, so each polyfill must be able to handle being installed twice, and avoid any bad behavior. The InputEvent polyfill, which is used on IE only to get correct UI behavior on input elements, was only able to handle being installed twice if each call was on the same copy of the library. In our tests, this is not the case. If we load the library 20 times, we get the polyfill installed 20 times. Since it was comparing addEventListener with the polyfilled version, this check would fail when the library was reloaded. Each "shaka" namespace was distinct. So on 20 hypothetical library loads, each polyfill would delegate to its predecessor, creating a stack some 40 functions deep. This would trigger a stack overflow when testing on IE. Instead, we can store the original addEventListener in some global place, such as on HTMLInputElement.prototype.originalAddEventListener. If that exists, the polyfill (or some version of it) was installed, so we don't install another. Found in Jasmine upgrade process (issue #1949) Change-Id: I714631c9b3ac5c59cf82a5cf7501cb544d1cb5cb