I was looking at the typo in 19178, and then the TODO in hexToInt. int.parse gained its radix parameter in https://code.google.com/p/dart/issues/detail?id=2624 around Dart SDK v1.1, so I bumped it in the pubspec.
Rewrite csslib's hexToInt
BUG= https://code.google.com/p/dart/issues/detail?id=19178
R=terry@google.com
Review URL: https://codereview.chromium.org//651823002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/csslib@41079 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/lib/src/property.dart b/lib/src/property.dart
index 8dc4dcb..777288a 100644
--- a/lib/src/property.dart
+++ b/lib/src/property.dart
@@ -291,34 +291,7 @@
}
}
- /**
- * [hex] hexadecimal string to convert to scalar.
- * returns hexadecimal number as an integer.
- * throws BadNumberFormatException if [hex] isn't a valid hexadecimal number.
- */
- // TODO(terry): Should be part of Dart standard library see bug
- // <http://code.google.com/p/dart/issues/detail?id=2624>
- static int hexToInt(String hex) {
- int val = 0;
-
- int len = hex.length;
- for (int i = 0; i < len; i++) {
- int hexDigit = hex.codeUnitAt(i);
- if (hexDigit >= 48 && hexDigit <= 57) {
- val += (hexDigit - 48) * (1 << (4 * (len - 1 - i)));
- } else if (hexDigit >= 65 && hexDigit <= 70) {
- // A..F
- val += (hexDigit - 55) * (1 << (4 * (len - 1 - i)));
- } else if (hexDigit >= 97 && hexDigit <= 102) {
- // a..f
- val += (hexDigit - 87) * (1 << (4 * (len - 1 - i)));
- } else {
- throw throw new FormatException("Bad hexadecimal value");
- }
- }
-
- return val;
- }
+ static int hexToInt(String hex) => int.parse(hex, radix: 16);
static String convertToHexString(int r, int g, int b, [num a]) {
String rHex = Color._numAs2DigitHex(Color._clamp(r, 0, 255));
diff --git a/pubspec.yaml b/pubspec.yaml
index 46c34cb..1c18c70 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -4,7 +4,7 @@
description: A library for parsing CSS.
homepage: https://www.dartlang.org
environment:
- sdk: '>=1.0.0 <2.0.0'
+ sdk: '>=1.1.0 <2.0.0'
dependencies:
args: '>=0.9.0 <0.13.0'
logging: '>=0.9.0 <0.10.0'