Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(393)

Unified Diff: sdk/lib/_internal/lib/js_string.dart

Issue 462463003: Add optional startIndex to String.replaceFirst (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Little fixes Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/lib/string_patch.dart ('k') | sdk/lib/_internal/lib/string_helper.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/lib/js_string.dart
diff --git a/sdk/lib/_internal/lib/js_string.dart b/sdk/lib/_internal/lib/js_string.dart
index a6962cb2432eb24af6e5a6f614d75bbdd3014bc9..ec1ece176fc8da1ce7579e6a203f91aea73a8647 100644
--- a/sdk/lib/_internal/lib/js_string.dart
+++ b/sdk/lib/_internal/lib/js_string.dart
@@ -70,9 +70,13 @@ class JSString extends Interceptor implements String, JSIndexable {
return stringReplaceAllFuncUnchecked(this, from, onMatch, onNonMatch);
}
- String replaceFirst(Pattern from, String to) {
+ String replaceFirst(Pattern from, String to, [int startIndex = 0]) {
checkString(to);
- return stringReplaceFirstUnchecked(this, from, to);
+ checkInt(startIndex);
+ if (startIndex < 0 || startIndex > this.length) {
+ throw new RangeError.range(startIndex, 0, this.length);
+ }
+ return stringReplaceFirstUnchecked(this, from, to, startIndex);
}
List<String> split(Pattern pattern) {
« no previous file with comments | « runtime/lib/string_patch.dart ('k') | sdk/lib/_internal/lib/string_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698