fix(styles): Escape \r characters in compiled text
Closes #5772 Closes #5835
This commit is contained in:
parent
0cb32c2fef
commit
92ddc62bed
|
@ -2,8 +2,8 @@ import {IS_DART, StringWrapper, isBlank} from 'angular2/src/facade/lang';
|
|||
|
||||
var CAMEL_CASE_REGEXP = /([A-Z])/g;
|
||||
var DASH_CASE_REGEXP = /-([a-z])/g;
|
||||
var SINGLE_QUOTE_ESCAPE_STRING_RE = /'|\\|\n|\$/g;
|
||||
var DOUBLE_QUOTE_ESCAPE_STRING_RE = /"|\\|\n|\$/g;
|
||||
var SINGLE_QUOTE_ESCAPE_STRING_RE = /'|\\|\n|\r|\$/g;
|
||||
var DOUBLE_QUOTE_ESCAPE_STRING_RE = /"|\\|\n|\r|\$/g;
|
||||
|
||||
export var MODULE_SUFFIX = IS_DART ? '.dart' : '.js';
|
||||
|
||||
|
@ -37,6 +37,8 @@ function escapeString(input: string, re: RegExp): string {
|
|||
return IS_DART ? '\\$' : '$';
|
||||
} else if (match[0] == '\n') {
|
||||
return '\\n';
|
||||
} else if (match[0] == '\r') {
|
||||
return '\\r';
|
||||
} else {
|
||||
return `\\${match[0]}`;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,9 @@ export function main() {
|
|||
it('should escape newlines',
|
||||
() => { expect(escapeSingleQuoteString('\n')).toEqual(`'\\n'`); });
|
||||
|
||||
it('should escape carriage returns',
|
||||
() => { expect(escapeSingleQuoteString('\r')).toEqual(`'\\r'`); });
|
||||
|
||||
if (IS_DART) {
|
||||
it('should escape $', () => { expect(escapeSingleQuoteString('$')).toEqual(`'\\$'`); });
|
||||
} else {
|
||||
|
@ -44,6 +47,9 @@ export function main() {
|
|||
it('should escape newlines',
|
||||
() => { expect(escapeDoubleQuoteString('\n')).toEqual(`"\\n"`); });
|
||||
|
||||
it('should escape carriage returns',
|
||||
() => { expect(escapeDoubleQuoteString('\r')).toEqual(`"\\r"`); });
|
||||
|
||||
if (IS_DART) {
|
||||
it('should escape $', () => { expect(escapeDoubleQuoteString('$')).toEqual(`"\\$"`); });
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue