Skip to content

Commit 0ae33b7

Browse files
committed
refactor(compiler): factorize common util code dash <-> camel
Closes angular#1114 Fixes angular#1097
1 parent b1dc623 commit 0ae33b7

File tree

4 files changed

+5
-19
lines changed

4 files changed

+5
-19
lines changed

modules/angular2/src/core/compiler/pipeline/compile_element.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {Decorator, Component, Viewport, DynamicComponent} from '../../annotation
66
import {ElementBinder} from '../element_binder';
77
import {ProtoElementInjector} from '../element_injector';
88
import * as viewModule from '../view';
9-
import {dashCaseToCamelCase} from './util';
9+
import {dashCaseToCamelCase} from '../string_utils';
1010

1111
import {AST} from 'angular2/change_detection';
1212

modules/angular2/src/core/compiler/pipeline/element_binder_builder.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {DirectiveMetadata} from '../directive_metadata';
1010
import {CompileStep} from './compile_step';
1111
import {CompileElement} from './compile_element';
1212
import {CompileControl} from './compile_control';
13-
import {dashCaseToCamelCase} from './util';
13+
import {dashCaseToCamelCase} from '../string_utils';
1414
import {setterFactory} from '../property_setter_factory'
1515

1616
/**

modules/angular2/src/core/compiler/property_setter_factory.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
11
import {StringWrapper, RegExpWrapper, BaseException, isPresent, isBlank, isString, stringify} from 'angular2/src/facade/lang';
22
import {ListWrapper, StringMapWrapper} from 'angular2/src/facade/collection';
33
import {DOM} from 'angular2/src/dom/dom_adapter';
4+
import {camelCaseToDashCase, dashCaseToCamelCase} from './string_utils';
45
import {reflector} from 'angular2/src/reflection/reflection';
56

6-
var DASH_CASE_REGEXP = RegExpWrapper.create('-([a-z])');
7-
var CAMEL_CASE_REGEXP = RegExpWrapper.create('([A-Z])');
8-
9-
export function dashCaseToCamelCase(input:string): string {
10-
return StringWrapper.replaceAllMapped(input, DASH_CASE_REGEXP, (m) => {
11-
return m[1].toUpperCase();
12-
});
13-
}
14-
15-
export function camelCaseToDashCase(input:string): string {
16-
return StringWrapper.replaceAllMapped(input, CAMEL_CASE_REGEXP, (m) => {
17-
return '-' + m[1].toLowerCase();
18-
});
19-
}
20-
217
const STYLE_SEPARATOR = '.';
228
var propertySettersCache = StringMapWrapper.create();
239
var innerHTMLSetterCache;

modules/angular2/src/core/compiler/pipeline/util.js renamed to modules/angular2/src/core/compiler/string_utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import {StringWrapper, RegExpWrapper} from 'angular2/src/facade/lang';
33
var DASH_CASE_REGEXP = RegExpWrapper.create('-([a-z])');
44
var CAMEL_CASE_REGEXP = RegExpWrapper.create('([A-Z])');
55

6-
export function dashCaseToCamelCase(input:string) {
6+
export function dashCaseToCamelCase(input:string): string {
77
return StringWrapper.replaceAllMapped(input, DASH_CASE_REGEXP, (m) => {
88
return m[1].toUpperCase();
99
});
1010
}
1111

12-
export function camelCaseToDashCase(input:string) {
12+
export function camelCaseToDashCase(input:string): string {
1313
return StringWrapper.replaceAllMapped(input, CAMEL_CASE_REGEXP, (m) => {
1414
return '-' + m[1].toLowerCase();
1515
});

0 commit comments

Comments
 (0)