Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Follow up changes to es5.d.ts
  • Loading branch information
navya9singh committed Jul 25, 2022
commit 04df1e18d9161035a18e0ea44eec8d1ce7d4f39d
2 changes: 1 addition & 1 deletion src/lib/es5.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ interface String {
/**
* Replaces text in a string, using a regular expression or search string.
* @param searchValue A string to search for.
Comment thread
navya9singh marked this conversation as resolved.
Outdated
* @param replaceValue A string containing the text to replace for every successful match of searchValue in this string.
* @param replaceValue A string containing the text to replace. When the searchvalue is a string, only the first match is replaced. If the searchValue is a Regexp, all matches are replaced if the g flag is set. Otherwise only the first one is.
Comment thread
navya9singh marked this conversation as resolved.
Outdated

@Josh-Cena Josh-Cena Jul 26, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an "interesting" aspect where "aaa-a".replace(/a/gy, "x") is xxx-a. I don't know how detailed we want it to be, but "all matches are replaced if the g flag is set" is technically not correct—and arguably less correct than before.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MDN's documentation for the sticky flag says that it ignores the global flag. If that's true, then I think it's fine to document it as-is, since you'll presumably find out about y long after g and hopefully read about the override.

However, is that consistent with your example? If there's some kind of interaction, it might be worth documenting.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an open issue for it: mdn/content#1454 I just haven't gotten around to fix it.

*/
replace(searchValue: string | RegExp, replaceValue: string): string;

Expand Down