Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken String.prototype.startsWith polyfill #190

Open
apolakipso opened this issue Jun 14, 2023 · 0 comments
Open

Broken String.prototype.startsWith polyfill #190

apolakipso opened this issue Jun 14, 2023 · 0 comments

Comments

@apolakipso
Copy link

apolakipso commented Jun 14, 2023

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

  • This polyfill should only be installed if String.prototype.startsWith does not exist.
  • The polyfill should implement a modern version with support for the position parameter (which would be functionally equivalent for code that uses it without anyway)

String.prototype.startsWith = function(prefix) {

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant