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

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

Issue 196533015: Fix bug in trim introduced by rewrite. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: without debug prints. Created 6 years, 9 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 | « no previous file | tests/corelib/string_trim2_test.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 1993a888cebd69ed32b0f92f37301407bce1a1f9..36372f46c9caee94754fe3ae48935c9a4d676443 100644
--- a/sdk/lib/_internal/lib/js_string.dart
+++ b/sdk/lib/_internal/lib/js_string.dart
@@ -218,12 +218,11 @@ class JSString extends Interceptor implements String, JSIndexable {
// Start by doing JS trim. Then check if it leaves a NEL at
// either end of the string.
String result = JS('String', '#.trim()', this);
-
if (result.length == 0) return result;
int firstCode = result.codeUnitAt(0);
int startIndex = 0;
if (firstCode == NEL) {
- startIndex = _skipLeadingWhitespace(this, 1);
+ startIndex = _skipLeadingWhitespace(result, 1);
if (startIndex == result.length) return "";
}
@@ -232,7 +231,7 @@ class JSString extends Interceptor implements String, JSIndexable {
// Therefore we don't need to verify that endIndex > startIndex.
int lastCode = result.codeUnitAt(endIndex - 1);
if (lastCode == NEL) {
- endIndex = _skipTrailingWhitespace(this, endIndex - 1);
+ endIndex = _skipTrailingWhitespace(result, endIndex - 1);
}
if (startIndex == 0 && endIndex == result.length) return result;
return JS('String', r'#.substring(#, #)', result, startIndex, endIndex);
« no previous file with comments | « no previous file | tests/corelib/string_trim2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698