microsoft / referencesource

Source from the Microsoft .NET Reference Source that represent a subset of the .NET Framework
https://referencesource.microsoft.com/
MIT License
3.13k stars 1.26k forks source link

Broken String.prototype.startsWith polyfill #190

Open apolakipso opened 1 year ago

apolakipso commented 1 year ago

This overwrites String.prototype.startsWith and breaks any code that expects a modern implementation to be present (like Office web add-ins or wherever this file gets loaded).

Issue

This implementation of String.prototype.startsWith doesn't support the position parameter, while all modern browsers do (it's also in here now: https://tc39.es/ecma262/#sec-string.prototype.startswith) - with the egregious bonus of not even checking whether a polyfill is even required.

Proposed solution

https://github.com/microsoft/referencesource/blob/51cf7850defa8a17d815b4700b67116e3fa283c2/System.Web.Extensions/Script/String.js#L19

NB: I'm referring to this version of the file in the wild, please let me know if this is the wrong source repo https://ajax.aspnetcdn.com/ajax/3.5/MicrosoftAjax.js