| OLD | NEW |
| (Empty) | |
| 1 <!-- |
| 2 @license |
| 3 Copyright (c) 2017 The Polymer Project Authors. All rights reserved. |
| 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
| 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
| 7 Code distributed by Google as part of the polymer project is also |
| 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 9 --> |
| 10 <link rel="import" href="boot.html"> |
| 11 <script> |
| 12 (function() { |
| 13 'use strict'; |
| 14 |
| 15 const caseMap = {}; |
| 16 const DASH_TO_CAMEL = /-[a-z]/g; |
| 17 const CAMEL_TO_DASH = /([A-Z])/g; |
| 18 |
| 19 /** |
| 20 * Module with utilities for converting between "dash-case" and "camelCase" |
| 21 * identifiers. |
| 22 * |
| 23 * @namespace |
| 24 * @memberof Polymer |
| 25 * @summary Module that provides utilities for converting between "dash-case" |
| 26 * and "camelCase". |
| 27 */ |
| 28 const CaseMap = { |
| 29 |
| 30 /** |
| 31 * Converts "dash-case" identifier (e.g. `foo-bar-baz`) to "camelCase" |
| 32 * (e.g. `fooBarBaz`). |
| 33 * |
| 34 * @memberof Polymer.CaseMap |
| 35 * @param {string} dash Dash-case identifier |
| 36 * @return {string} Camel-case representation of the identifier |
| 37 */ |
| 38 dashToCamelCase(dash) { |
| 39 return caseMap[dash] || ( |
| 40 caseMap[dash] = dash.indexOf('-') < 0 ? dash : dash.replace(DASH_TO_CAME
L, |
| 41 (m) => m[1].toUpperCase() |
| 42 ) |
| 43 ); |
| 44 }, |
| 45 |
| 46 /** |
| 47 * Converts "camelCase" identifier (e.g. `fooBarBaz`) to "dash-case" |
| 48 * (e.g. `foo-bar-baz`). |
| 49 * |
| 50 * @memberof Polymer.CaseMap |
| 51 * @param {string} camel Camel-case identifier |
| 52 * @return {string} Dash-case representation of the identifier |
| 53 */ |
| 54 camelToDashCase(camel) { |
| 55 return caseMap[camel] || ( |
| 56 caseMap[camel] = camel.replace(CAMEL_TO_DASH, '-$1').toLowerCase() |
| 57 ); |
| 58 } |
| 59 |
| 60 }; |
| 61 |
| 62 Polymer.CaseMap = CaseMap; |
| 63 })(); |
| 64 </script> |
| OLD | NEW |