diff --git a/modules/angular2/src/core/compiler/pipeline/compile_element.js b/modules/angular2/src/core/compiler/pipeline/compile_element.js index 22ea0d33a0..0ffc08b1fc 100644 --- a/modules/angular2/src/core/compiler/pipeline/compile_element.js +++ b/modules/angular2/src/core/compiler/pipeline/compile_element.js @@ -6,7 +6,7 @@ import {Decorator, Component, Viewport, DynamicComponent} from '../../annotation import {ElementBinder} from '../element_binder'; import {ProtoElementInjector} from '../element_injector'; import * as viewModule from '../view'; -import {dashCaseToCamelCase} from './util'; +import {dashCaseToCamelCase} from '../string_utils'; import {AST} from 'angular2/change_detection'; diff --git a/modules/angular2/src/core/compiler/pipeline/element_binder_builder.js b/modules/angular2/src/core/compiler/pipeline/element_binder_builder.js index 3d3aef5ee8..af7c52c3e5 100644 --- a/modules/angular2/src/core/compiler/pipeline/element_binder_builder.js +++ b/modules/angular2/src/core/compiler/pipeline/element_binder_builder.js @@ -10,7 +10,7 @@ import {DirectiveMetadata} from '../directive_metadata'; import {CompileStep} from './compile_step'; import {CompileElement} from './compile_element'; import {CompileControl} from './compile_control'; -import {dashCaseToCamelCase} from './util'; +import {dashCaseToCamelCase} from '../string_utils'; import {setterFactory} from '../property_setter_factory' /** diff --git a/modules/angular2/src/core/compiler/property_setter_factory.js b/modules/angular2/src/core/compiler/property_setter_factory.js index 3696635f7b..3232603143 100644 --- a/modules/angular2/src/core/compiler/property_setter_factory.js +++ b/modules/angular2/src/core/compiler/property_setter_factory.js @@ -1,23 +1,9 @@ import {StringWrapper, RegExpWrapper, BaseException, isPresent, isBlank, isString, stringify} from 'angular2/src/facade/lang'; import {ListWrapper, StringMapWrapper} from 'angular2/src/facade/collection'; import {DOM} from 'angular2/src/dom/dom_adapter'; +import {camelCaseToDashCase, dashCaseToCamelCase} from './string_utils'; import {reflector} from 'angular2/src/reflection/reflection'; -var DASH_CASE_REGEXP = RegExpWrapper.create('-([a-z])'); -var CAMEL_CASE_REGEXP = RegExpWrapper.create('([A-Z])'); - -export function dashCaseToCamelCase(input:string): string { - return StringWrapper.replaceAllMapped(input, DASH_CASE_REGEXP, (m) => { - return m[1].toUpperCase(); - }); -} - -export function camelCaseToDashCase(input:string): string { - return StringWrapper.replaceAllMapped(input, CAMEL_CASE_REGEXP, (m) => { - return '-' + m[1].toLowerCase(); - }); -} - const STYLE_SEPARATOR = '.'; var propertySettersCache = StringMapWrapper.create(); var innerHTMLSetterCache; diff --git a/modules/angular2/src/core/compiler/pipeline/util.js b/modules/angular2/src/core/compiler/string_utils.js similarity index 77% rename from modules/angular2/src/core/compiler/pipeline/util.js rename to modules/angular2/src/core/compiler/string_utils.js index 7ef4f4c50b..566bccc18c 100644 --- a/modules/angular2/src/core/compiler/pipeline/util.js +++ b/modules/angular2/src/core/compiler/string_utils.js @@ -3,13 +3,13 @@ import {StringWrapper, RegExpWrapper} from 'angular2/src/facade/lang'; var DASH_CASE_REGEXP = RegExpWrapper.create('-([a-z])'); var CAMEL_CASE_REGEXP = RegExpWrapper.create('([A-Z])'); -export function dashCaseToCamelCase(input:string) { +export function dashCaseToCamelCase(input:string): string { return StringWrapper.replaceAllMapped(input, DASH_CASE_REGEXP, (m) => { return m[1].toUpperCase(); }); } -export function camelCaseToDashCase(input:string) { +export function camelCaseToDashCase(input:string): string { return StringWrapper.replaceAllMapped(input, CAMEL_CASE_REGEXP, (m) => { return '-' + m[1].toLowerCase(); });