Files
angular-docs-cn/modules/@angular/platform-browser/src/dom/util.ts
T

24 lines
679 B
TypeScript
Raw Normal View History

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
2016-05-31 15:22:59 -07:00
import {StringWrapper} from '../facade/lang';
var CAMEL_CASE_REGEXP = /([A-Z])/g;
var DASH_CASE_REGEXP = /-([a-z])/g;
export function camelCaseToDashCase(input: string): string {
2016-06-08 16:38:52 -07:00
return StringWrapper.replaceAllMapped(
2016-10-04 15:57:37 -07:00
input, CAMEL_CASE_REGEXP, (m: string[]) => '-' + m[1].toLowerCase());
}
export function dashCaseToCamelCase(input: string): string {
2016-06-08 16:38:52 -07:00
return StringWrapper.replaceAllMapped(
2016-10-04 15:57:37 -07:00
input, DASH_CASE_REGEXP, (m: string[]) => m[1].toUpperCase());
2015-05-18 11:57:20 -07:00
}