refactor(compiler): factorize common util code dash <-> camel
Closes #1114 Fixes #1097
This commit is contained in:
parent
b1dc6239ef
commit
0ae33b7e3c
@ -6,7 +6,7 @@ import {Decorator, Component, Viewport, DynamicComponent} from '../../annotation
|
|||||||
import {ElementBinder} from '../element_binder';
|
import {ElementBinder} from '../element_binder';
|
||||||
import {ProtoElementInjector} from '../element_injector';
|
import {ProtoElementInjector} from '../element_injector';
|
||||||
import * as viewModule from '../view';
|
import * as viewModule from '../view';
|
||||||
import {dashCaseToCamelCase} from './util';
|
import {dashCaseToCamelCase} from '../string_utils';
|
||||||
|
|
||||||
import {AST} from 'angular2/change_detection';
|
import {AST} from 'angular2/change_detection';
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import {DirectiveMetadata} from '../directive_metadata';
|
|||||||
import {CompileStep} from './compile_step';
|
import {CompileStep} from './compile_step';
|
||||||
import {CompileElement} from './compile_element';
|
import {CompileElement} from './compile_element';
|
||||||
import {CompileControl} from './compile_control';
|
import {CompileControl} from './compile_control';
|
||||||
import {dashCaseToCamelCase} from './util';
|
import {dashCaseToCamelCase} from '../string_utils';
|
||||||
import {setterFactory} from '../property_setter_factory'
|
import {setterFactory} from '../property_setter_factory'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,23 +1,9 @@
|
|||||||
import {StringWrapper, RegExpWrapper, BaseException, isPresent, isBlank, isString, stringify} from 'angular2/src/facade/lang';
|
import {StringWrapper, RegExpWrapper, BaseException, isPresent, isBlank, isString, stringify} from 'angular2/src/facade/lang';
|
||||||
import {ListWrapper, StringMapWrapper} from 'angular2/src/facade/collection';
|
import {ListWrapper, StringMapWrapper} from 'angular2/src/facade/collection';
|
||||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||||
|
import {camelCaseToDashCase, dashCaseToCamelCase} from './string_utils';
|
||||||
import {reflector} from 'angular2/src/reflection/reflection';
|
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 = '.';
|
const STYLE_SEPARATOR = '.';
|
||||||
var propertySettersCache = StringMapWrapper.create();
|
var propertySettersCache = StringMapWrapper.create();
|
||||||
var innerHTMLSetterCache;
|
var innerHTMLSetterCache;
|
||||||
|
@ -3,13 +3,13 @@ import {StringWrapper, RegExpWrapper} from 'angular2/src/facade/lang';
|
|||||||
var DASH_CASE_REGEXP = RegExpWrapper.create('-([a-z])');
|
var DASH_CASE_REGEXP = RegExpWrapper.create('-([a-z])');
|
||||||
var CAMEL_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 StringWrapper.replaceAllMapped(input, DASH_CASE_REGEXP, (m) => {
|
||||||
return m[1].toUpperCase();
|
return m[1].toUpperCase();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function camelCaseToDashCase(input:string) {
|
export function camelCaseToDashCase(input:string): string {
|
||||||
return StringWrapper.replaceAllMapped(input, CAMEL_CASE_REGEXP, (m) => {
|
return StringWrapper.replaceAllMapped(input, CAMEL_CASE_REGEXP, (m) => {
|
||||||
return '-' + m[1].toLowerCase();
|
return '-' + m[1].toLowerCase();
|
||||||
});
|
});
|
Loading…
x
Reference in New Issue
Block a user