| Index: sdk/lib/html/dart2js/html_dart2js.dart
|
| diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
|
| index 708bdb016ca2a9c401377247d8acbd598516f465..39841fb3ecc4c5ce3e2a5cd4ff9a7704f855b07d 100644
|
| --- a/sdk/lib/html/dart2js/html_dart2js.dart
|
| +++ b/sdk/lib/html/dart2js/html_dart2js.dart
|
| @@ -28345,9 +28345,38 @@ class _DataAttributeMap implements Map<String, String> {
|
| bool get isNotEmpty => !isEmpty;
|
|
|
| // Helpers.
|
| - String _attr(String key) => 'data-$key';
|
| + String _attr(String key) => 'data-${_toHyphenedName(key)}'; // todo add hyphens where capitalized
|
| bool _matches(String key) => key.startsWith('data-');
|
| - String _strip(String key) => key.substring(5);
|
| + String _strip(String key) => _toCamelCase(key.substring(5)); // todo: capitalize and remove hyphens
|
| +
|
| + /**
|
| + * Converts a string name with hyphens into an identifier, by removing hyphens
|
| + * and capitalizing the following letter. Optionally [startUppercase] to
|
| + * captialize the first letter.
|
| + */
|
| + String _toCamelCase(String hyphenedName, {bool startUppercase: false}) {
|
| + var segments = hyphenedName.split('-');
|
| + int start = startUppercase ? 0 : 1;
|
| + for (int i = start; i < segments.length; i++) {
|
| + var segment = segments[i];
|
| + if (segment.length > 0) {
|
| + // Character between 'a'..'z' mapped to 'A'..'Z'
|
| + segments[i] = '${segment[0].toUpperCase()}${segment.substring(1)}';
|
| + }
|
| + }
|
| + return segments.join('');
|
| + }
|
| +
|
| + /** Reverse of [toCamelCase]. */
|
| + String _toHyphenedName(String word) {
|
| + var sb = new StringBuffer();
|
| + for (int i = 0; i < word.length; i++) {
|
| + var lower = word[i].toLowerCase();
|
| + if (word[i] != lower && i > 0) sb.write('-');
|
| + sb.write(lower);
|
| + }
|
| + return sb.toString();
|
| + }
|
| }
|
| // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
| // for details. All rights reserved. Use of this source code is governed by a
|
|
|