-
Notifications
You must be signed in to change notification settings - Fork 517
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(js): horizontal and vertical scroll improvements (#2649)
- Loading branch information
Showing
7 changed files
with
25 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
live-examples/js-examples/intl/intl-listformat-prototype-formattoparts.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,15 @@ | ||
const paragraph = | ||
'The quick brown fox jumps over the lazy dog. If the dog barked, was it really lazy?'; | ||
const paragraph = "I think Ruth's dog is cuter than your dog!"; | ||
|
||
const searchTerm = 'dog'; | ||
const indexOfFirst = paragraph.indexOf(searchTerm); | ||
|
||
console.log( | ||
`The index of the first "${searchTerm}" from the beginning is ${indexOfFirst}`, | ||
); | ||
// Expected output: "The index of the first "dog" from the beginning is 40" | ||
console.log(`The index of the first "${searchTerm}" is ${indexOfFirst}`); | ||
// Expected output: "The index of the first "dog" is 7" | ||
|
||
console.log( | ||
`The index of the 2nd "${searchTerm}" is ${paragraph.indexOf( | ||
`The index of the second "${searchTerm}" is ${paragraph.indexOf( | ||
searchTerm, | ||
indexOfFirst + 1, | ||
)}`, | ||
); | ||
// Expected output: "The index of the 2nd "dog" is 52" | ||
// Expected output: "The index of the second "dog" is 41" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
const paragraph = | ||
'The quick brown fox jumps over the lazy dog. If the dog barked, was it really lazy?'; | ||
const paragraph = "I think Ruth's dog is cuter than your dog!"; | ||
|
||
const searchTerm = 'dog'; | ||
|
||
console.log( | ||
`The index of the first "${searchTerm}" from the end is ${paragraph.lastIndexOf( | ||
searchTerm, | ||
)}`, | ||
`Index of the last ${searchTerm} is ${paragraph.lastIndexOf(searchTerm)}`, | ||
); | ||
// Expected output: "The index of the first "dog" from the end is 52" | ||
// Expected output: "Index of the last "dog" is 38" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
const p = | ||
'The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?'; | ||
const paragraph = "I think Ruth's dog is cuter than your dog!"; | ||
|
||
console.log(p.replace('dog', 'monkey')); | ||
// Expected output: "The quick brown fox jumps over the lazy monkey. If the dog reacted, was it really lazy?" | ||
console.log(paragraph.replace("Ruth's", 'my')); | ||
// Expected output: "I think my dog is cuter than your dog!" | ||
|
||
const regex = /Dog/i; | ||
console.log(p.replace(regex, 'ferret')); | ||
// Expected output: "The quick brown fox jumps over the lazy ferret. If the dog reacted, was it really lazy?" | ||
console.log(paragraph.replace(regex, 'ferret')); | ||
// Expected output: "I think Ruth's ferret is cuter than your dog!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
const p = | ||
'The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?'; | ||
const paragraph = "I think Ruth's dog is cuter than your dog!"; | ||
|
||
console.log(p.replaceAll('dog', 'monkey')); | ||
// Expected output: "The quick brown fox jumps over the lazy monkey. If the monkey reacted, was it really lazy?" | ||
console.log(paragraph.replaceAll('dog', 'monkey')); | ||
// Expected output: "I think Ruth's monkey is cuter than your monkey!" | ||
|
||
// Global flag required when calling replaceAll with regex | ||
const regex = /Dog/gi; | ||
console.log(p.replaceAll(regex, 'ferret')); | ||
// Expected output: "The quick brown fox jumps over the lazy ferret. If the ferret reacted, was it really lazy?" | ||
console.log(paragraph.replaceAll(regex, 'ferret')); | ||
// Expected output: "I think Ruth's ferret is cuter than your ferret!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
const paragraph = | ||
'The quick brown fox jumps over the lazy dog. If the dog barked, was it really lazy?'; | ||
const paragraph = "I think Ruth's dog is cuter than your dog!"; | ||
|
||
// Any character that is not a word character or whitespace | ||
const regex = /[^\w\s]/g; | ||
// Anything not a word character, whitespace or apostrophe | ||
const regex = /[^\w\s']/g; | ||
|
||
console.log(paragraph.search(regex)); | ||
// Expected output: 43 | ||
// Expected output: 41 | ||
|
||
console.log(paragraph[paragraph.search(regex)]); | ||
// Expected output: "." | ||
// Expected output: "!" |