refactor(facade): inline StringWrapper (#12051)
This commit is contained in:
parent
bb35fcb562
commit
8c975ed156
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
|
|
||||||
import {StringWrapper, isPresent} from '../facade/lang';
|
import {isPresent} from '../facade/lang';
|
||||||
import {WebDriverAdapter} from '../web_driver_adapter';
|
import {WebDriverAdapter} from '../web_driver_adapter';
|
||||||
import {PerfLogEvent, PerfLogFeatures, WebDriverExtension} from '../web_driver_extension';
|
import {PerfLogEvent, PerfLogFeatures, WebDriverExtension} from '../web_driver_extension';
|
||||||
|
|
||||||
@ -48,6 +48,6 @@ export class FirefoxDriverExtension extends WebDriverExtension {
|
|||||||
perfLogFeatures(): PerfLogFeatures { return new PerfLogFeatures({render: true, gc: true}); }
|
perfLogFeatures(): PerfLogFeatures { return new PerfLogFeatures({render: true, gc: true}); }
|
||||||
|
|
||||||
supports(capabilities: {[key: string]: any}): boolean {
|
supports(capabilities: {[key: string]: any}): boolean {
|
||||||
return StringWrapper.equals(capabilities['browserName'].toLowerCase(), 'firefox');
|
return capabilities['browserName'].toLowerCase() === 'firefox';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
|
|
||||||
import {StringWrapper, isBlank, isPresent} from '../facade/lang';
|
import {isBlank, isPresent} from '../facade/lang';
|
||||||
import {WebDriverAdapter} from '../web_driver_adapter';
|
import {WebDriverAdapter} from '../web_driver_adapter';
|
||||||
import {PerfLogEvent, PerfLogFeatures, WebDriverExtension} from '../web_driver_extension';
|
import {PerfLogEvent, PerfLogFeatures, WebDriverExtension} from '../web_driver_extension';
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ export class IOsDriverExtension extends WebDriverExtension {
|
|||||||
var records: any[] = [];
|
var records: any[] = [];
|
||||||
entries.forEach(entry => {
|
entries.forEach(entry => {
|
||||||
var message = JSON.parse(entry['message'])['message'];
|
var message = JSON.parse(entry['message'])['message'];
|
||||||
if (StringWrapper.equals(message['method'], 'Timeline.eventRecorded')) {
|
if (message['method'] === 'Timeline.eventRecorded') {
|
||||||
records.push(message['params']['record']);
|
records.push(message['params']['record']);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -62,19 +62,16 @@ export class IOsDriverExtension extends WebDriverExtension {
|
|||||||
var startTime = record['startTime'];
|
var startTime = record['startTime'];
|
||||||
var endTime = record['endTime'];
|
var endTime = record['endTime'];
|
||||||
|
|
||||||
if (StringWrapper.equals(type, 'FunctionCall') &&
|
if (type === 'FunctionCall' && (isBlank(data) || data['scriptName'] !== 'InjectedScript')) {
|
||||||
(isBlank(data) || !StringWrapper.equals(data['scriptName'], 'InjectedScript'))) {
|
|
||||||
events.push(createStartEvent('script', startTime));
|
events.push(createStartEvent('script', startTime));
|
||||||
endEvent = createEndEvent('script', endTime);
|
endEvent = createEndEvent('script', endTime);
|
||||||
} else if (StringWrapper.equals(type, 'Time')) {
|
} else if (type === 'Time') {
|
||||||
events.push(createMarkStartEvent(data['message'], startTime));
|
events.push(createMarkStartEvent(data['message'], startTime));
|
||||||
} else if (StringWrapper.equals(type, 'TimeEnd')) {
|
} else if (type === 'TimeEnd') {
|
||||||
events.push(createMarkEndEvent(data['message'], startTime));
|
events.push(createMarkEndEvent(data['message'], startTime));
|
||||||
} else if (
|
} else if (
|
||||||
StringWrapper.equals(type, 'RecalculateStyles') || StringWrapper.equals(type, 'Layout') ||
|
type === 'RecalculateStyles' || type === 'Layout' || type === 'UpdateLayerTree' ||
|
||||||
StringWrapper.equals(type, 'UpdateLayerTree') || StringWrapper.equals(type, 'Paint') ||
|
type === 'Paint' || type === 'Rasterize' || type === 'CompositeLayers') {
|
||||||
StringWrapper.equals(type, 'Rasterize') ||
|
|
||||||
StringWrapper.equals(type, 'CompositeLayers')) {
|
|
||||||
events.push(createStartEvent('render', startTime));
|
events.push(createStartEvent('render', startTime));
|
||||||
endEvent = createEndEvent('render', endTime);
|
endEvent = createEndEvent('render', endTime);
|
||||||
}
|
}
|
||||||
@ -92,7 +89,7 @@ export class IOsDriverExtension extends WebDriverExtension {
|
|||||||
perfLogFeatures(): PerfLogFeatures { return new PerfLogFeatures({render: true}); }
|
perfLogFeatures(): PerfLogFeatures { return new PerfLogFeatures({render: true}); }
|
||||||
|
|
||||||
supports(capabilities: {[key: string]: any}): boolean {
|
supports(capabilities: {[key: string]: any}): boolean {
|
||||||
return StringWrapper.equals(capabilities['browserName'].toLowerCase(), 'safari');
|
return capabilities['browserName'].toLowerCase() === 'safari';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/testing/testing_internal';
|
import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/testing/testing_internal';
|
||||||
|
|
||||||
import {Options, ReflectiveInjector, WebDriverExtension} from '../index';
|
import {Options, ReflectiveInjector, WebDriverExtension} from '../index';
|
||||||
import {StringWrapper, isPresent} from '../src/facade/lang';
|
import {isPresent} from '../src/facade/lang';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
function createExtension(ids: any[], caps: any) {
|
function createExtension(ids: any[], caps: any) {
|
||||||
@ -52,6 +52,6 @@ class MockExtension extends WebDriverExtension {
|
|||||||
constructor(public id: string) { super(); }
|
constructor(public id: string) { super(); }
|
||||||
|
|
||||||
supports(capabilities: {[key: string]: any}): boolean {
|
supports(capabilities: {[key: string]: any}): boolean {
|
||||||
return StringWrapper.equals(capabilities['browser'], this.id);
|
return capabilities['browser'] === this.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import {Component} from '@angular/core';
|
|||||||
import {TestBed, async} from '@angular/core/testing';
|
import {TestBed, async} from '@angular/core/testing';
|
||||||
import {expect} from '@angular/platform-browser/testing/matchers';
|
import {expect} from '@angular/platform-browser/testing/matchers';
|
||||||
|
|
||||||
import {Json, StringWrapper} from '../../src/facade/lang';
|
import {Json} from '../../src/facade/lang';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
describe('JsonPipe', () => {
|
describe('JsonPipe', () => {
|
||||||
@ -20,7 +20,7 @@ export function main() {
|
|||||||
var inceptionObjString: string;
|
var inceptionObjString: string;
|
||||||
var pipe: JsonPipe;
|
var pipe: JsonPipe;
|
||||||
|
|
||||||
function normalize(obj: string): string { return StringWrapper.replace(obj, regNewLine, ''); }
|
function normalize(obj: string): string { return obj.replace(regNewLine, ''); }
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
inceptionObj = {dream: {dream: {dream: 'Limbo'}}};
|
inceptionObj = {dream: {dream: {dream: 'Limbo'}}};
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
import * as chars from '../chars';
|
import * as chars from '../chars';
|
||||||
import {BaseError} from '../facade/errors';
|
import {BaseError} from '../facade/errors';
|
||||||
import {StringWrapper, isPresent} from '../facade/lang';
|
import {isPresent} from '../facade/lang';
|
||||||
|
|
||||||
export enum CssTokenType {
|
export enum CssTokenType {
|
||||||
EOF,
|
EOF,
|
||||||
@ -155,7 +155,7 @@ export class CssScanner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
peekAt(index: number): number {
|
peekAt(index: number): number {
|
||||||
return index >= this.length ? chars.$EOF : StringWrapper.charCodeAt(this.input, index);
|
return index >= this.length ? chars.$EOF : this.input.charCodeAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
consumeEmptyStatements(): void {
|
consumeEmptyStatements(): void {
|
||||||
@ -310,7 +310,7 @@ export class CssScanner {
|
|||||||
return this.scanCharacter();
|
return this.scanCharacter();
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.error(`Unexpected character [${StringWrapper.fromCharCode(peek)}]`);
|
return this.error(`Unexpected character [${String.fromCharCode(peek)}]`);
|
||||||
}
|
}
|
||||||
|
|
||||||
scanComment(): CssToken {
|
scanComment(): CssToken {
|
||||||
@ -476,8 +476,7 @@ export class CssScanner {
|
|||||||
var index: number = this.index;
|
var index: number = this.index;
|
||||||
var column: number = this.column;
|
var column: number = this.column;
|
||||||
var line: number = this.line;
|
var line: number = this.line;
|
||||||
errorTokenValue =
|
errorTokenValue = isPresent(errorTokenValue) ? errorTokenValue : String.fromCharCode(this.peek);
|
||||||
isPresent(errorTokenValue) ? errorTokenValue : StringWrapper.fromCharCode(this.peek);
|
|
||||||
var invalidToken = new CssToken(index, column, line, CssTokenType.Invalid, errorTokenValue);
|
var invalidToken = new CssToken(index, column, line, CssTokenType.Invalid, errorTokenValue);
|
||||||
var errorMessage =
|
var errorMessage =
|
||||||
generateErrorMessage(this.input, message, errorTokenValue, index, line, column);
|
generateErrorMessage(this.input, message, errorTokenValue, index, line, column);
|
||||||
@ -696,11 +695,11 @@ function isValidCssCharacter(code: number, mode: CssLexerMode): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function charCode(input: string, index: number): number {
|
function charCode(input: string, index: number): number {
|
||||||
return index >= input.length ? chars.$EOF : StringWrapper.charCodeAt(input, index);
|
return index >= input.length ? chars.$EOF : input.charCodeAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
function charStr(code: number): string {
|
function charStr(code: number): string {
|
||||||
return StringWrapper.fromCharCode(code);
|
return String.fromCharCode(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isNewline(code: number): boolean {
|
export function isNewline(code: number): boolean {
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import * as chars from '../chars';
|
import * as chars from '../chars';
|
||||||
import {NumberWrapper, StringJoiner, StringWrapper, isPresent} from '../facade/lang';
|
import {NumberWrapper, StringJoiner, isPresent} from '../facade/lang';
|
||||||
|
|
||||||
export enum TokenType {
|
export enum TokenType {
|
||||||
Character,
|
Character,
|
||||||
@ -93,7 +93,7 @@ export class Token {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function newCharacterToken(index: number, code: number): Token {
|
function newCharacterToken(index: number, code: number): Token {
|
||||||
return new Token(index, TokenType.Character, code, StringWrapper.fromCharCode(code));
|
return new Token(index, TokenType.Character, code, String.fromCharCode(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
function newIdentifierToken(index: number, text: string): Token {
|
function newIdentifierToken(index: number, text: string): Token {
|
||||||
@ -133,8 +133,7 @@ class _Scanner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
advance() {
|
advance() {
|
||||||
this.peek =
|
this.peek = ++this.index >= this.length ? chars.$EOF : this.input.charCodeAt(this.index);
|
||||||
++this.index >= this.length ? chars.$EOF : StringWrapper.charCodeAt(this.input, this.index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scanToken(): Token {
|
scanToken(): Token {
|
||||||
@ -146,7 +145,7 @@ class _Scanner {
|
|||||||
peek = chars.$EOF;
|
peek = chars.$EOF;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
peek = StringWrapper.charCodeAt(input, index);
|
peek = input.charCodeAt(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,16 +186,16 @@ class _Scanner {
|
|||||||
case chars.$SLASH:
|
case chars.$SLASH:
|
||||||
case chars.$PERCENT:
|
case chars.$PERCENT:
|
||||||
case chars.$CARET:
|
case chars.$CARET:
|
||||||
return this.scanOperator(start, StringWrapper.fromCharCode(peek));
|
return this.scanOperator(start, String.fromCharCode(peek));
|
||||||
case chars.$QUESTION:
|
case chars.$QUESTION:
|
||||||
return this.scanComplexOperator(start, '?', chars.$PERIOD, '.');
|
return this.scanComplexOperator(start, '?', chars.$PERIOD, '.');
|
||||||
case chars.$LT:
|
case chars.$LT:
|
||||||
case chars.$GT:
|
case chars.$GT:
|
||||||
return this.scanComplexOperator(start, StringWrapper.fromCharCode(peek), chars.$EQ, '=');
|
return this.scanComplexOperator(start, String.fromCharCode(peek), chars.$EQ, '=');
|
||||||
case chars.$BANG:
|
case chars.$BANG:
|
||||||
case chars.$EQ:
|
case chars.$EQ:
|
||||||
return this.scanComplexOperator(
|
return this.scanComplexOperator(
|
||||||
start, StringWrapper.fromCharCode(peek), chars.$EQ, '=', chars.$EQ, '=');
|
start, String.fromCharCode(peek), chars.$EQ, '=', chars.$EQ, '=');
|
||||||
case chars.$AMPERSAND:
|
case chars.$AMPERSAND:
|
||||||
return this.scanComplexOperator(start, '&', chars.$AMPERSAND, '&');
|
return this.scanComplexOperator(start, '&', chars.$AMPERSAND, '&');
|
||||||
case chars.$BAR:
|
case chars.$BAR:
|
||||||
@ -207,7 +206,7 @@ class _Scanner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.advance();
|
this.advance();
|
||||||
return this.error(`Unexpected character [${StringWrapper.fromCharCode(peek)}]`, 0);
|
return this.error(`Unexpected character [${String.fromCharCode(peek)}]`, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
scanCharacter(start: number, code: number): Token {
|
scanCharacter(start: number, code: number): Token {
|
||||||
@ -310,7 +309,7 @@ class _Scanner {
|
|||||||
unescapedCode = unescape(this.peek);
|
unescapedCode = unescape(this.peek);
|
||||||
this.advance();
|
this.advance();
|
||||||
}
|
}
|
||||||
buffer.add(StringWrapper.fromCharCode(unescapedCode));
|
buffer.add(String.fromCharCode(unescapedCode));
|
||||||
marker = this.index;
|
marker = this.index;
|
||||||
} else if (this.peek == chars.$EOF) {
|
} else if (this.peek == chars.$EOF) {
|
||||||
return this.error('Unterminated quote', 0);
|
return this.error('Unterminated quote', 0);
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
|
|
||||||
import * as chars from '../chars';
|
import * as chars from '../chars';
|
||||||
import {StringWrapper, escapeRegExp, isBlank, isPresent} from '../facade/lang';
|
import {escapeRegExp, isBlank, isPresent} from '../facade/lang';
|
||||||
import {DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig} from '../ml_parser/interpolation_config';
|
import {DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig} from '../ml_parser/interpolation_config';
|
||||||
|
|
||||||
import {AST, ASTWithSource, AstVisitor, Binary, BindingPipe, Chain, Conditional, EmptyExpr, FunctionCall, ImplicitReceiver, Interpolation, KeyedRead, KeyedWrite, LiteralArray, LiteralMap, LiteralPrimitive, MethodCall, ParseSpan, ParserError, PrefixNot, PropertyRead, PropertyWrite, Quote, SafeMethodCall, SafePropertyRead, TemplateBinding} from './ast';
|
import {AST, ASTWithSource, AstVisitor, Binary, BindingPipe, Chain, Conditional, EmptyExpr, FunctionCall, ImplicitReceiver, Interpolation, KeyedRead, KeyedWrite, LiteralArray, LiteralMap, LiteralPrimitive, MethodCall, ParseSpan, ParserError, PrefixNot, PropertyRead, PropertyWrite, Quote, SafeMethodCall, SafePropertyRead, TemplateBinding} from './ast';
|
||||||
@ -122,7 +122,7 @@ export class Parser {
|
|||||||
input: string, location: string,
|
input: string, location: string,
|
||||||
interpolationConfig: InterpolationConfig = DEFAULT_INTERPOLATION_CONFIG): SplitInterpolation {
|
interpolationConfig: InterpolationConfig = DEFAULT_INTERPOLATION_CONFIG): SplitInterpolation {
|
||||||
const regexp = _createInterpolateRegExp(interpolationConfig);
|
const regexp = _createInterpolateRegExp(interpolationConfig);
|
||||||
const parts = StringWrapper.split(input, regexp);
|
const parts = input.split(regexp);
|
||||||
if (parts.length <= 1) {
|
if (parts.length <= 1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -160,8 +160,8 @@ export class Parser {
|
|||||||
private _commentStart(input: string): number {
|
private _commentStart(input: string): number {
|
||||||
var outerQuote: number = null;
|
var outerQuote: number = null;
|
||||||
for (let i = 0; i < input.length - 1; i++) {
|
for (let i = 0; i < input.length - 1; i++) {
|
||||||
const char = StringWrapper.charCodeAt(input, i);
|
const char = input.charCodeAt(i);
|
||||||
const nextChar = StringWrapper.charCodeAt(input, i + 1);
|
const nextChar = input.charCodeAt(i + 1);
|
||||||
|
|
||||||
if (char === chars.$SLASH && nextChar == chars.$SLASH && isBlank(outerQuote)) return i;
|
if (char === chars.$SLASH && nextChar == chars.$SLASH && isBlank(outerQuote)) return i;
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ export class Parser {
|
|||||||
private _checkNoInterpolation(
|
private _checkNoInterpolation(
|
||||||
input: string, location: any, interpolationConfig: InterpolationConfig): void {
|
input: string, location: any, interpolationConfig: InterpolationConfig): void {
|
||||||
var regexp = _createInterpolateRegExp(interpolationConfig);
|
var regexp = _createInterpolateRegExp(interpolationConfig);
|
||||||
var parts = StringWrapper.split(input, regexp);
|
var parts = input.split(regexp);
|
||||||
if (parts.length > 1) {
|
if (parts.length > 1) {
|
||||||
this._reportError(
|
this._reportError(
|
||||||
`Got interpolation (${interpolationConfig.start}${interpolationConfig.end}) where expression was expected`,
|
`Got interpolation (${interpolationConfig.start}${interpolationConfig.end}) where expression was expected`,
|
||||||
@ -239,7 +239,7 @@ export class _ParseAST {
|
|||||||
|
|
||||||
expectCharacter(code: number) {
|
expectCharacter(code: number) {
|
||||||
if (this.optionalCharacter(code)) return;
|
if (this.optionalCharacter(code)) return;
|
||||||
this.error(`Missing expected ${StringWrapper.fromCharCode(code)}`);
|
this.error(`Missing expected ${String.fromCharCode(code)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
optionalOperator(op: string): boolean {
|
optionalOperator(op: string): boolean {
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {StringWrapper, isBlank, isPresent, isString} from '../facade/lang';
|
import {isBlank, isPresent, isString} from '../facade/lang';
|
||||||
|
|
||||||
import * as o from './output_ast';
|
import * as o from './output_ast';
|
||||||
|
|
||||||
@ -409,8 +409,7 @@ export function escapeIdentifier(
|
|||||||
if (isBlank(input)) {
|
if (isBlank(input)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var body = StringWrapper.replaceAllMapped(
|
var body = input.replace(_SINGLE_QUOTE_ESCAPE_STRING_RE, (...match: string[]) => {
|
||||||
input, _SINGLE_QUOTE_ESCAPE_STRING_RE, (match: any /** TODO #9100 */) => {
|
|
||||||
if (match[0] == '$') {
|
if (match[0] == '$') {
|
||||||
return escapeDollar ? '\\$' : '$';
|
return escapeDollar ? '\\$' : '$';
|
||||||
} else if (match[0] == '\n') {
|
} else if (match[0] == '\n') {
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// Some of the code comes from WebComponents.JS
|
// Some of the code comes from WebComponents.JS
|
||||||
// https://github.com/webcomponents/webcomponentsjs/blob/master/src/HTMLImports/path.js
|
// https://github.com/webcomponents/webcomponentsjs/blob/master/src/HTMLImports/path.js
|
||||||
|
|
||||||
import {StringWrapper, isBlank, isPresent} from './facade/lang';
|
import {isBlank, isPresent} from './facade/lang';
|
||||||
|
|
||||||
import {UrlResolver} from './url_resolver';
|
import {UrlResolver} from './url_resolver';
|
||||||
|
|
||||||
@ -30,8 +30,8 @@ export function isStyleUrlResolvable(url: string): boolean {
|
|||||||
export function extractStyleUrls(
|
export function extractStyleUrls(
|
||||||
resolver: UrlResolver, baseUrl: string, cssText: string): StyleWithImports {
|
resolver: UrlResolver, baseUrl: string, cssText: string): StyleWithImports {
|
||||||
var foundUrls: string[] = [];
|
var foundUrls: string[] = [];
|
||||||
var modifiedCssText = StringWrapper.replaceAllMapped(cssText, _cssImportRe, (m: string[]) => {
|
var modifiedCssText = cssText.replace(_cssImportRe, function(...m: string[]) {
|
||||||
var url = isPresent(m[1]) ? m[1] : m[2];
|
const url = isPresent(m[1]) ? m[1] : m[2];
|
||||||
if (!isStyleUrlResolvable(url)) {
|
if (!isStyleUrlResolvable(url)) {
|
||||||
// Do not attempt to resolve non-package absolute URLs with URI scheme
|
// Do not attempt to resolve non-package absolute URLs with URI scheme
|
||||||
return m[0];
|
return m[0];
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import {Inject, Injectable, PACKAGE_ROOT_URL} from '@angular/core';
|
import {Inject, Injectable, PACKAGE_ROOT_URL} from '@angular/core';
|
||||||
|
|
||||||
import {StringWrapper, isBlank, isPresent} from './facade/lang';
|
import {isBlank, isPresent} from './facade/lang';
|
||||||
|
|
||||||
|
|
||||||
const _ASSET_SCHEME = 'asset:';
|
const _ASSET_SCHEME = 'asset:';
|
||||||
@ -74,8 +74,8 @@ export class UrlResolver {
|
|||||||
var pathSegements = path.split(/\//);
|
var pathSegements = path.split(/\//);
|
||||||
resolvedUrl = `asset:${pathSegements[0]}/lib/${pathSegements.slice(1).join('/')}`;
|
resolvedUrl = `asset:${pathSegements[0]}/lib/${pathSegements.slice(1).join('/')}`;
|
||||||
} else {
|
} else {
|
||||||
prefix = StringWrapper.stripRight(prefix, '/');
|
prefix = prefix.replace(/\/+$/, '');
|
||||||
path = StringWrapper.stripLeft(path, '/');
|
path = path.replace(/^\/+/, '');
|
||||||
return `${prefix}/${path}`;
|
return `${prefix}/${path}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {CompileTokenMetadata} from './compile_metadata';
|
import {CompileTokenMetadata} from './compile_metadata';
|
||||||
import {StringWrapper, isArray, isBlank, isPresent, isPrimitive, isStrictStringMap} from './facade/lang';
|
import {isArray, isBlank, isPresent, isPrimitive, isStrictStringMap} from './facade/lang';
|
||||||
import * as o from './output/output_ast';
|
import * as o from './output/output_ast';
|
||||||
|
|
||||||
export const MODULE_SUFFIX = '';
|
export const MODULE_SUFFIX = '';
|
||||||
@ -15,8 +15,7 @@ export const MODULE_SUFFIX = '';
|
|||||||
var CAMEL_CASE_REGEXP = /([A-Z])/g;
|
var CAMEL_CASE_REGEXP = /([A-Z])/g;
|
||||||
|
|
||||||
export function camelCaseToDashCase(input: string): string {
|
export function camelCaseToDashCase(input: string): string {
|
||||||
return StringWrapper.replaceAllMapped(
|
return input.replace(CAMEL_CASE_REGEXP, (...m: any[]) => '-' + m[1].toLowerCase());
|
||||||
input, CAMEL_CASE_REGEXP, (m: string[]) => '-' + m[1].toLowerCase());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function splitAtColon(input: string, defaultValues: string[]): string[] {
|
export function splitAtColon(input: string, defaultValues: string[]): string[] {
|
||||||
@ -34,7 +33,7 @@ function _splitAt(input: string, character: string, defaultValues: string[]): st
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function sanitizeIdentifier(name: string): string {
|
export function sanitizeIdentifier(name: string): string {
|
||||||
return StringWrapper.replaceAll(name, /\W/g, '_');
|
return name.replace(/\W/g, '_');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function visitValue(value: any, visitor: ValueVisitor, context: any): any {
|
export function visitValue(value: any, visitor: ValueVisitor, context: any): any {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {CompileDirectiveMetadata} from '../compile_metadata';
|
import {CompileDirectiveMetadata} from '../compile_metadata';
|
||||||
import {StringWrapper, isPresent} from '../facade/lang';
|
import {isPresent} from '../facade/lang';
|
||||||
import {identifierToken} from '../identifiers';
|
import {identifierToken} from '../identifiers';
|
||||||
import * as o from '../output/output_ast';
|
import * as o from '../output/output_ast';
|
||||||
import {BoundEventAst, DirectiveAst} from '../template_parser/template_ast';
|
import {BoundEventAst, DirectiveAst} from '../template_parser/template_ast';
|
||||||
@ -200,5 +200,5 @@ function convertStmtIntoExpression(stmt: o.Statement): o.Expression {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function santitizeEventName(name: string): string {
|
function santitizeEventName(name: string): string {
|
||||||
return StringWrapper.replaceAll(name, /[^a-zA-Z_]/g, '_');
|
return name.replace(/[^a-zA-Z_]/g, '_');
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import {ViewEncapsulation} from '@angular/core';
|
|||||||
|
|
||||||
import {CompileDirectiveMetadata, CompileIdentifierMetadata, CompileTokenMetadata} from '../compile_metadata';
|
import {CompileDirectiveMetadata, CompileIdentifierMetadata, CompileTokenMetadata} from '../compile_metadata';
|
||||||
import {ListWrapper} from '../facade/collection';
|
import {ListWrapper} from '../facade/collection';
|
||||||
import {StringWrapper, isPresent} from '../facade/lang';
|
import {isPresent} from '../facade/lang';
|
||||||
import {Identifiers, identifierToken, resolveIdentifier} from '../identifiers';
|
import {Identifiers, identifierToken, resolveIdentifier} from '../identifiers';
|
||||||
import * as o from '../output/output_ast';
|
import * as o from '../output/output_ast';
|
||||||
import {ChangeDetectorStatus, ViewType, isDefaultChangeDetectionStrategy} from '../private_import_core';
|
import {ChangeDetectorStatus, ViewType, isDefaultChangeDetectionStrategy} from '../private_import_core';
|
||||||
@ -376,7 +376,7 @@ function mapToKeyValueArray(data: {[key: string]: string}): string[][] {
|
|||||||
Object.keys(data).forEach(name => { entryArray.push([name, data[name]]); });
|
Object.keys(data).forEach(name => { entryArray.push([name, data[name]]); });
|
||||||
// We need to sort to get a defined output order
|
// We need to sort to get a defined output order
|
||||||
// for tests and for caching generated artifacts...
|
// for tests and for caching generated artifacts...
|
||||||
ListWrapper.sort(entryArray, (entry1, entry2) => StringWrapper.compare(entry1[0], entry2[0]));
|
ListWrapper.sort(entryArray);
|
||||||
return entryArray;
|
return entryArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {AST, AstVisitor, Binary, BindingPipe, Chain, Conditional, FunctionCall, ImplicitReceiver, Interpolation, KeyedRead, KeyedWrite, LiteralArray, LiteralMap, LiteralPrimitive, MethodCall, PrefixNot, PropertyRead, PropertyWrite, Quote, SafeMethodCall, SafePropertyRead} from '../../src/expression_parser/ast';
|
import {AST, AstVisitor, Binary, BindingPipe, Chain, Conditional, FunctionCall, ImplicitReceiver, Interpolation, KeyedRead, KeyedWrite, LiteralArray, LiteralMap, LiteralPrimitive, MethodCall, PrefixNot, PropertyRead, PropertyWrite, Quote, SafeMethodCall, SafePropertyRead} from '../../src/expression_parser/ast';
|
||||||
import {StringWrapper, isString} from '../../src/facade/lang';
|
import {isString} from '../../src/facade/lang';
|
||||||
import {DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig} from '../../src/ml_parser/interpolation_config';
|
import {DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig} from '../../src/ml_parser/interpolation_config';
|
||||||
|
|
||||||
class Unparser implements AstVisitor {
|
class Unparser implements AstVisitor {
|
||||||
@ -134,7 +134,7 @@ class Unparser implements AstVisitor {
|
|||||||
|
|
||||||
visitLiteralPrimitive(ast: LiteralPrimitive, context: any) {
|
visitLiteralPrimitive(ast: LiteralPrimitive, context: any) {
|
||||||
if (isString(ast.value)) {
|
if (isString(ast.value)) {
|
||||||
this._expression += `"${StringWrapper.replaceAll(ast.value, Unparser._quoteRegExp, '\"')}"`;
|
this._expression += `"${ast.value.replace( Unparser._quoteRegExp, '\"')}"`;
|
||||||
} else {
|
} else {
|
||||||
this._expression += `${ast.value}`;
|
this._expression += `${ast.value}`;
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,6 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {StringWrapper} from '../src/facade/lang';
|
|
||||||
|
|
||||||
import {OpaqueToken} from './di';
|
import {OpaqueToken} from './di';
|
||||||
|
|
||||||
|
|
||||||
@ -38,7 +36,7 @@ export const APP_ID_RANDOM_PROVIDER = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function _randomChar(): string {
|
function _randomChar(): string {
|
||||||
return StringWrapper.fromCharCode(97 + Math.floor(Math.random() * 25));
|
return String.fromCharCode(97 + Math.floor(Math.random() * 25));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,7 +12,6 @@ import {beforeEach, describe, expect, it} from '@angular/core/testing/testing_in
|
|||||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||||
|
|
||||||
import {iterateListLike} from '../../src/facade/collection';
|
import {iterateListLike} from '../../src/facade/collection';
|
||||||
import {StringWrapper} from '../../src/facade/lang';
|
|
||||||
|
|
||||||
interface _JsQueryList {
|
interface _JsQueryList {
|
||||||
filter(c: any): any;
|
filter(c: any): any;
|
||||||
@ -104,8 +103,8 @@ export function main() {
|
|||||||
it('should support toString', () => {
|
it('should support toString', () => {
|
||||||
queryList.reset(['one', 'two']);
|
queryList.reset(['one', 'two']);
|
||||||
var listString = queryList.toString();
|
var listString = queryList.toString();
|
||||||
expect(StringWrapper.contains(listString, 'one')).toBeTruthy();
|
expect(listString.indexOf('one') != -1).toBeTruthy();
|
||||||
expect(StringWrapper.contains(listString, 'two')).toBeTruthy();
|
expect(listString.indexOf('two') != -1).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support first and last', () => {
|
it('should support first and last', () => {
|
||||||
|
@ -137,73 +137,6 @@ export function stringify(token: any): string {
|
|||||||
return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
|
return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
export class StringWrapper {
|
|
||||||
static fromCharCode(code: number): string { return String.fromCharCode(code); }
|
|
||||||
|
|
||||||
static charCodeAt(s: string, index: number): number { return s.charCodeAt(index); }
|
|
||||||
|
|
||||||
static split(s: string, regExp: RegExp): string[] { return s.split(regExp); }
|
|
||||||
|
|
||||||
static equals(s: string, s2: string): boolean { return s === s2; }
|
|
||||||
|
|
||||||
static stripLeft(s: string, charVal: string): string {
|
|
||||||
if (s && s.length) {
|
|
||||||
var pos = 0;
|
|
||||||
for (var i = 0; i < s.length; i++) {
|
|
||||||
if (s[i] != charVal) break;
|
|
||||||
pos++;
|
|
||||||
}
|
|
||||||
s = s.substring(pos);
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
static stripRight(s: string, charVal: string): string {
|
|
||||||
if (s && s.length) {
|
|
||||||
var pos = s.length;
|
|
||||||
for (var i = s.length - 1; i >= 0; i--) {
|
|
||||||
if (s[i] != charVal) break;
|
|
||||||
pos--;
|
|
||||||
}
|
|
||||||
s = s.substring(0, pos);
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
static replace(s: string, from: string, replace: string): string {
|
|
||||||
return s.replace(from, replace);
|
|
||||||
}
|
|
||||||
|
|
||||||
static replaceAll(s: string, from: RegExp, replace: string): string {
|
|
||||||
return s.replace(from, replace);
|
|
||||||
}
|
|
||||||
|
|
||||||
static slice<T>(s: string, from: number = 0, to: number = null): string {
|
|
||||||
return s.slice(from, to === null ? undefined : to);
|
|
||||||
}
|
|
||||||
|
|
||||||
static replaceAllMapped(s: string, from: RegExp, cb: (m: string[]) => string): string {
|
|
||||||
return s.replace(from, function(...matches: any[]) {
|
|
||||||
// Remove offset & string from the result array
|
|
||||||
matches.splice(-2, 2);
|
|
||||||
// The callback receives match, p1, ..., pn
|
|
||||||
return cb(matches);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
static contains(s: string, substr: string): boolean { return s.indexOf(substr) != -1; }
|
|
||||||
|
|
||||||
static compare(a: string, b: string): number {
|
|
||||||
if (a < b) {
|
|
||||||
return -1;
|
|
||||||
} else if (a > b) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class StringJoiner {
|
export class StringJoiner {
|
||||||
constructor(public parts: string[] = []) {}
|
constructor(public parts: string[] = []) {}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {NumberWrapper, StringWrapper, escapeRegExp, hasConstructor} from '../src/lang';
|
import {NumberWrapper, escapeRegExp, hasConstructor} from '../src/lang';
|
||||||
|
|
||||||
class MySuperclass {}
|
class MySuperclass {}
|
||||||
class MySubclass extends MySuperclass {}
|
class MySubclass extends MySuperclass {}
|
||||||
@ -50,92 +50,4 @@ export function main() {
|
|||||||
() => { expect(NumberWrapper.isNumeric('2a')).toBe(false); });
|
() => { expect(NumberWrapper.isNumeric('2a')).toBe(false); });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('String', () => {
|
|
||||||
var s: string;
|
|
||||||
|
|
||||||
describe('slice', () => {
|
|
||||||
beforeEach(() => { s = 'abcdefghij'; });
|
|
||||||
|
|
||||||
it('should return the whole string if neither start nor end are specified',
|
|
||||||
() => { expect(StringWrapper.slice(s)).toEqual('abcdefghij'); });
|
|
||||||
|
|
||||||
it('should return up to the end if end is not specified',
|
|
||||||
() => { expect(StringWrapper.slice(s, 1)).toEqual('bcdefghij'); });
|
|
||||||
|
|
||||||
it('should support negative start',
|
|
||||||
() => { expect(StringWrapper.slice(s, -1)).toEqual('j'); });
|
|
||||||
|
|
||||||
it('should support negative end',
|
|
||||||
() => { expect(StringWrapper.slice(s, -3, -1)).toEqual('hi'); });
|
|
||||||
|
|
||||||
it('should return empty string if start is greater than end', () => {
|
|
||||||
expect(StringWrapper.slice(s, 4, 2)).toEqual('');
|
|
||||||
expect(StringWrapper.slice(s, -2, -4)).toEqual('');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('stripLeft', () => {
|
|
||||||
it('should strip the first character of the string if it matches the provided input', () => {
|
|
||||||
var input = '~angular2 is amazing';
|
|
||||||
var expectedOutput = 'angular2 is amazing';
|
|
||||||
|
|
||||||
expect(StringWrapper.stripLeft(input, '~')).toEqual(expectedOutput);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should keep stripping characters from the start until the first unmatched character',
|
|
||||||
() => {
|
|
||||||
var input = '#####hello';
|
|
||||||
var expectedOutput = 'hello';
|
|
||||||
expect(StringWrapper.stripLeft(input, '#')).toEqual(expectedOutput);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not alter the provided input if the first character does not match the provided input',
|
|
||||||
() => {
|
|
||||||
var input = '+angular2 is amazing';
|
|
||||||
expect(StringWrapper.stripLeft(input, '*')).toEqual(input);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not do any alterations when an empty string or null value is passed in', () => {
|
|
||||||
expect(StringWrapper.stripLeft('', 'S')).toEqual('');
|
|
||||||
expect(StringWrapper.stripLeft(null, 'S')).toEqual(null);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('stripRight', () => {
|
|
||||||
it('should strip the first character of the string if it matches the provided input', () => {
|
|
||||||
var input = 'angular2 is amazing!';
|
|
||||||
var expectedOutput = 'angular2 is amazing';
|
|
||||||
|
|
||||||
expect(StringWrapper.stripRight(input, '!')).toEqual(expectedOutput);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not alter the provided input if the first character does not match the provided input',
|
|
||||||
() => {
|
|
||||||
var input = 'angular2 is amazing+';
|
|
||||||
|
|
||||||
expect(StringWrapper.stripRight(input, '*')).toEqual(input);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should keep stripping characters from the end until the first unmatched character',
|
|
||||||
() => {
|
|
||||||
var input = 'hi&!&&&&&';
|
|
||||||
var expectedOutput = 'hi&!';
|
|
||||||
expect(StringWrapper.stripRight(input, '&')).toEqual(expectedOutput);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not do any alterations when an empty string or null value is passed in', () => {
|
|
||||||
expect(StringWrapper.stripRight('', 'S')).toEqual('');
|
|
||||||
expect(StringWrapper.stripRight(null, 'S')).toEqual(null);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('hasConstructor', () => {
|
|
||||||
it('should be true when the type matches',
|
|
||||||
() => { expect(hasConstructor(new MySuperclass(), MySuperclass)).toEqual(true); });
|
|
||||||
|
|
||||||
it('should be false for subtypes',
|
|
||||||
() => { expect(hasConstructor(new MySubclass(), MySuperclass)).toEqual(false); });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
import {Directive, ElementRef, Host, Input, OnDestroy, Optional, Renderer, forwardRef} from '@angular/core';
|
import {Directive, ElementRef, Host, Input, OnDestroy, Optional, Renderer, forwardRef} from '@angular/core';
|
||||||
|
|
||||||
import {MapWrapper} from '../facade/collection';
|
import {MapWrapper} from '../facade/collection';
|
||||||
import {StringWrapper, isBlank, isPresent, isPrimitive, looseIdentical} from '../facade/lang';
|
import {isBlank, isPresent, isPrimitive, looseIdentical} from '../facade/lang';
|
||||||
|
|
||||||
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from './control_value_accessor';
|
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from './control_value_accessor';
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ export const SELECT_VALUE_ACCESSOR: any = {
|
|||||||
function _buildValueString(id: string, value: any): string {
|
function _buildValueString(id: string, value: any): string {
|
||||||
if (isBlank(id)) return `${value}`;
|
if (isBlank(id)) return `${value}`;
|
||||||
if (!isPrimitive(value)) value = 'Object';
|
if (!isPrimitive(value)) value = 'Object';
|
||||||
return StringWrapper.slice(`${id}: ${value}`, 0, 50);
|
return `${id}: ${value}`.slice(0, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _extractId(valueString: string): string {
|
function _extractId(valueString: string): string {
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
import {Directive, ElementRef, Host, Input, OnDestroy, OpaqueToken, Optional, Renderer, Type, forwardRef} from '@angular/core';
|
import {Directive, ElementRef, Host, Input, OnDestroy, OpaqueToken, Optional, Renderer, Type, forwardRef} from '@angular/core';
|
||||||
|
|
||||||
import {MapWrapper} from '../facade/collection';
|
import {MapWrapper} from '../facade/collection';
|
||||||
import {StringWrapper, isBlank, isPresent, isPrimitive, isString, looseIdentical} from '../facade/lang';
|
import {isBlank, isPresent, isPrimitive, isString, looseIdentical} from '../facade/lang';
|
||||||
|
|
||||||
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from './control_value_accessor';
|
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from './control_value_accessor';
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ function _buildValueString(id: string, value: any): string {
|
|||||||
if (isBlank(id)) return `${value}`;
|
if (isBlank(id)) return `${value}`;
|
||||||
if (isString(value)) value = `'${value}'`;
|
if (isString(value)) value = `'${value}'`;
|
||||||
if (!isPrimitive(value)) value = 'Object';
|
if (!isPrimitive(value)) value = 'Object';
|
||||||
return StringWrapper.slice(`${id}: ${value}`, 0, 50);
|
return `${id}: ${value}`.slice(0, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _extractId(valueString: string): string {
|
function _extractId(valueString: string): string {
|
||||||
|
@ -12,7 +12,7 @@ import {Observer} from 'rxjs/Observer';
|
|||||||
|
|
||||||
import {ResponseOptions} from '../base_response_options';
|
import {ResponseOptions} from '../base_response_options';
|
||||||
import {ReadyState, RequestMethod, ResponseType} from '../enums';
|
import {ReadyState, RequestMethod, ResponseType} from '../enums';
|
||||||
import {StringWrapper, isPresent} from '../facade/lang';
|
import {isPresent} from '../facade/lang';
|
||||||
import {Connection, ConnectionBackend} from '../interfaces';
|
import {Connection, ConnectionBackend} from '../interfaces';
|
||||||
import {Request} from '../static_request';
|
import {Request} from '../static_request';
|
||||||
import {Response} from '../static_response';
|
import {Response} from '../static_response';
|
||||||
@ -75,7 +75,7 @@ export class JSONPConnection_ extends JSONPConnection {
|
|||||||
let callback = _dom.requestCallback(this._id);
|
let callback = _dom.requestCallback(this._id);
|
||||||
let url: string = req.url;
|
let url: string = req.url;
|
||||||
if (url.indexOf('=JSONP_CALLBACK&') > -1) {
|
if (url.indexOf('=JSONP_CALLBACK&') > -1) {
|
||||||
url = StringWrapper.replace(url, '=JSONP_CALLBACK&', `=${callback}&`);
|
url = url.replace('=JSONP_CALLBACK&', `=${callback}&`);
|
||||||
} else if (url.lastIndexOf('=JSONP_CALLBACK') === url.length - '=JSONP_CALLBACK'.length) {
|
} else if (url.lastIndexOf('=JSONP_CALLBACK') === url.length - '=JSONP_CALLBACK'.length) {
|
||||||
url = url.substring(0, url.length - '=JSONP_CALLBACK'.length) + `=${callback}`;
|
url = url.substring(0, url.length - '=JSONP_CALLBACK'.length) + `=${callback}`;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {StringWrapper, isPresent} from '../src/facade/lang';
|
import {isPresent} from '../src/facade/lang';
|
||||||
|
|
||||||
import {Body} from './body';
|
import {Body} from './body';
|
||||||
import {ContentType, RequestMethod, ResponseContentType} from './enums';
|
import {ContentType, RequestMethod, ResponseContentType} from './enums';
|
||||||
@ -82,7 +82,7 @@ export class Request extends Body {
|
|||||||
let search = requestOptions.search.toString();
|
let search = requestOptions.search.toString();
|
||||||
if (search.length > 0) {
|
if (search.length > 0) {
|
||||||
let prefix = '?';
|
let prefix = '?';
|
||||||
if (StringWrapper.contains(this.url, '?')) {
|
if (this.url.indexOf('?') != -1) {
|
||||||
prefix = (this.url[this.url.length - 1] == '&') ? '' : '&';
|
prefix = (this.url[this.url.length - 1] == '&') ? '' : '&';
|
||||||
}
|
}
|
||||||
// TODO: just delete search-query-looking string in url?
|
// TODO: just delete search-query-looking string in url?
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {Inject, Injectable, RenderComponentType, Renderer, RootRenderer, ViewEncapsulation} from '@angular/core';
|
import {Inject, Injectable, RenderComponentType, Renderer, RootRenderer, ViewEncapsulation} from '@angular/core';
|
||||||
import {Json, StringWrapper, isArray, isBlank, isPresent, isString, stringify} from '../facade/lang';
|
import {Json, isArray, isBlank, isPresent, isString, stringify} from '../facade/lang';
|
||||||
import {AnimationKeyframe, AnimationPlayer, AnimationStyles, RenderDebugInfo} from '../private_import_core';
|
import {AnimationKeyframe, AnimationPlayer, AnimationStyles, RenderDebugInfo} from '../private_import_core';
|
||||||
|
|
||||||
import {AnimationDriver} from './animation_driver';
|
import {AnimationDriver} from './animation_driver';
|
||||||
@ -192,13 +192,12 @@ export class DomRenderer implements Renderer {
|
|||||||
setBindingDebugInfo(renderElement: any, propertyName: string, propertyValue: string): void {
|
setBindingDebugInfo(renderElement: any, propertyName: string, propertyValue: string): void {
|
||||||
var dashCasedPropertyName = camelCaseToDashCase(propertyName);
|
var dashCasedPropertyName = camelCaseToDashCase(propertyName);
|
||||||
if (getDOM().isCommentNode(renderElement)) {
|
if (getDOM().isCommentNode(renderElement)) {
|
||||||
const existingBindings = StringWrapper.replaceAll(getDOM().getText(renderElement), /\n/g, '')
|
const existingBindings =
|
||||||
.match(TEMPLATE_BINDINGS_EXP);
|
getDOM().getText(renderElement).replace(/\n/g, '').match(TEMPLATE_BINDINGS_EXP);
|
||||||
var parsedBindings = Json.parse(existingBindings[1]);
|
var parsedBindings = Json.parse(existingBindings[1]);
|
||||||
(parsedBindings as any /** TODO #9100 */)[dashCasedPropertyName] = propertyValue;
|
(parsedBindings as any /** TODO #9100 */)[dashCasedPropertyName] = propertyValue;
|
||||||
getDOM().setText(
|
getDOM().setText(
|
||||||
renderElement,
|
renderElement, TEMPLATE_COMMENT_TEXT.replace('{}', Json.stringify(parsedBindings)));
|
||||||
StringWrapper.replace(TEMPLATE_COMMENT_TEXT, '{}', Json.stringify(parsedBindings)));
|
|
||||||
} else {
|
} else {
|
||||||
this.setElementAttribute(renderElement, propertyName, propertyValue);
|
this.setElementAttribute(renderElement, propertyName, propertyValue);
|
||||||
}
|
}
|
||||||
@ -272,11 +271,11 @@ export const HOST_ATTR = `_nghost-${COMPONENT_VARIABLE}`;
|
|||||||
export const CONTENT_ATTR = `_ngcontent-${COMPONENT_VARIABLE}`;
|
export const CONTENT_ATTR = `_ngcontent-${COMPONENT_VARIABLE}`;
|
||||||
|
|
||||||
function _shimContentAttribute(componentShortId: string): string {
|
function _shimContentAttribute(componentShortId: string): string {
|
||||||
return StringWrapper.replaceAll(CONTENT_ATTR, COMPONENT_REGEX, componentShortId);
|
return CONTENT_ATTR.replace(COMPONENT_REGEX, componentShortId);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _shimHostAttribute(componentShortId: string): string {
|
function _shimHostAttribute(componentShortId: string): string {
|
||||||
return StringWrapper.replaceAll(HOST_ATTR, COMPONENT_REGEX, componentShortId);
|
return HOST_ATTR.replace(COMPONENT_REGEX, componentShortId);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _flattenStyles(compId: string, styles: Array<any|any[]>, target: string[]): string[] {
|
function _flattenStyles(compId: string, styles: Array<any|any[]>, target: string[]): string[] {
|
||||||
@ -285,7 +284,7 @@ function _flattenStyles(compId: string, styles: Array<any|any[]>, target: string
|
|||||||
if (isArray(style)) {
|
if (isArray(style)) {
|
||||||
_flattenStyles(compId, style, target);
|
_flattenStyles(compId, style, target);
|
||||||
} else {
|
} else {
|
||||||
style = StringWrapper.replaceAll(style, COMPONENT_REGEX, compId);
|
style = style.replace(COMPONENT_REGEX, compId);
|
||||||
target.push(style);
|
target.push(style);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
import {Injectable, NgZone} from '@angular/core';
|
import {Injectable, NgZone} from '@angular/core';
|
||||||
|
|
||||||
import {ListWrapper} from '../../facade/collection';
|
import {ListWrapper} from '../../facade/collection';
|
||||||
import {StringWrapper, isPresent} from '../../facade/lang';
|
import {isPresent} from '../../facade/lang';
|
||||||
import {getDOM} from '../dom_adapter';
|
import {getDOM} from '../dom_adapter';
|
||||||
|
|
||||||
import {EventManagerPlugin} from './event_manager';
|
import {EventManagerPlugin} from './event_manager';
|
||||||
@ -50,9 +50,7 @@ export class KeyEventsPlugin extends EventManagerPlugin {
|
|||||||
var parts: string[] = eventName.toLowerCase().split('.');
|
var parts: string[] = eventName.toLowerCase().split('.');
|
||||||
|
|
||||||
var domEventName = parts.shift();
|
var domEventName = parts.shift();
|
||||||
if ((parts.length === 0) ||
|
if ((parts.length === 0) || !(domEventName === 'keydown' || domEventName === 'keyup')) {
|
||||||
!(StringWrapper.equals(domEventName, 'keydown') ||
|
|
||||||
StringWrapper.equals(domEventName, 'keyup'))) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,9 +80,9 @@ export class KeyEventsPlugin extends EventManagerPlugin {
|
|||||||
var fullKey = '';
|
var fullKey = '';
|
||||||
var key = getDOM().getEventKey(event);
|
var key = getDOM().getEventKey(event);
|
||||||
key = key.toLowerCase();
|
key = key.toLowerCase();
|
||||||
if (StringWrapper.equals(key, ' ')) {
|
if (key === ' ') {
|
||||||
key = 'space'; // for readability
|
key = 'space'; // for readability
|
||||||
} else if (StringWrapper.equals(key, '.')) {
|
} else if (key === '.') {
|
||||||
key = 'dot'; // because '.' is used as a separator in event names
|
key = 'dot'; // because '.' is used as a separator in event names
|
||||||
}
|
}
|
||||||
modifierKeys.forEach(modifierName => {
|
modifierKeys.forEach(modifierName => {
|
||||||
@ -102,7 +100,7 @@ export class KeyEventsPlugin extends EventManagerPlugin {
|
|||||||
static eventCallback(element: HTMLElement, fullKey: any, handler: Function, zone: NgZone):
|
static eventCallback(element: HTMLElement, fullKey: any, handler: Function, zone: NgZone):
|
||||||
Function {
|
Function {
|
||||||
return (event: any /** TODO #9100 */) => {
|
return (event: any /** TODO #9100 */) => {
|
||||||
if (StringWrapper.equals(KeyEventsPlugin.getEventFullKey(event), fullKey)) {
|
if (KeyEventsPlugin.getEventFullKey(event) === fullKey) {
|
||||||
zone.runGuarded(() => handler(event));
|
zone.runGuarded(() => handler(event));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -6,18 +6,14 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {StringWrapper} from '../facade/lang';
|
|
||||||
|
|
||||||
var CAMEL_CASE_REGEXP = /([A-Z])/g;
|
var CAMEL_CASE_REGEXP = /([A-Z])/g;
|
||||||
var DASH_CASE_REGEXP = /-([a-z])/g;
|
var DASH_CASE_REGEXP = /-([a-z])/g;
|
||||||
|
|
||||||
|
|
||||||
export function camelCaseToDashCase(input: string): string {
|
export function camelCaseToDashCase(input: string): string {
|
||||||
return StringWrapper.replaceAllMapped(
|
return input.replace(CAMEL_CASE_REGEXP, (...m: string[]) => '-' + m[1].toLowerCase());
|
||||||
input, CAMEL_CASE_REGEXP, (m: string[]) => '-' + m[1].toLowerCase());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function dashCaseToCamelCase(input: string): string {
|
export function dashCaseToCamelCase(input: string): string {
|
||||||
return StringWrapper.replaceAllMapped(
|
return input.replace(DASH_CASE_REGEXP, (...m: string[]) => m[1].toUpperCase());
|
||||||
input, DASH_CASE_REGEXP, (m: string[]) => m[1].toUpperCase());
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {AUTO_STYLE} from '@angular/core';
|
import {AUTO_STYLE} from '@angular/core';
|
||||||
import {StringWrapper, isNumber, isPresent} from '../facade/lang';
|
|
||||||
|
import {isNumber, isPresent} from '../facade/lang';
|
||||||
import {AnimationKeyframe, AnimationStyles} from '../private_import_core';
|
import {AnimationKeyframe, AnimationStyles} from '../private_import_core';
|
||||||
|
|
||||||
import {AnimationDriver} from './animation_driver';
|
import {AnimationDriver} from './animation_driver';
|
||||||
@ -97,7 +98,7 @@ const _$PERIOD = 46;
|
|||||||
|
|
||||||
function _findDimensionalSuffix(value: string): string {
|
function _findDimensionalSuffix(value: string): string {
|
||||||
for (var i = 0; i < value.length; i++) {
|
for (var i = 0; i < value.length; i++) {
|
||||||
var c = StringWrapper.charCodeAt(value, i);
|
var c = value.charCodeAt(i);
|
||||||
if ((c >= _$0 && c <= _$9) || c == _$PERIOD) continue;
|
if ((c >= _$0 && c <= _$9) || c == _$PERIOD) continue;
|
||||||
return value.substring(i, value.length);
|
return value.substring(i, value.length);
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
import {NgZone} from '@angular/core';
|
import {NgZone} from '@angular/core';
|
||||||
|
|
||||||
import {ListWrapper} from './facade/collection';
|
import {ListWrapper} from './facade/collection';
|
||||||
import {StringWrapper, global, isPresent, isString} from './facade/lang';
|
import {global, isPresent, isString} from './facade/lang';
|
||||||
import {getDOM} from './private_import_platform-browser';
|
import {getDOM} from './private_import_platform-browser';
|
||||||
|
|
||||||
export class BrowserDetection {
|
export class BrowserDetection {
|
||||||
@ -83,16 +83,12 @@ export function el(html: string): HTMLElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function normalizeCSS(css: string): string {
|
export function normalizeCSS(css: string): string {
|
||||||
css = StringWrapper.replaceAll(css, /\s+/g, ' ');
|
return css.replace(/\s+/g, ' ')
|
||||||
css = StringWrapper.replaceAll(css, /:\s/g, ':');
|
.replace(/:\s/g, ':')
|
||||||
css = StringWrapper.replaceAll(css, /'/g, '"');
|
.replace(/'/g, '"')
|
||||||
css = StringWrapper.replaceAll(css, / }/g, '}');
|
.replace(/ }/g, '}')
|
||||||
css = StringWrapper.replaceAllMapped(
|
.replace(/url\((\"|\s)(.+)(\"|\s)\)(\s*)/g, (...match: string[]) => `url("${match[2]}")`)
|
||||||
css, /url\((\"|\s)(.+)(\"|\s)\)(\s*)/g,
|
.replace(/\[(.+)=([^"\]]+)\]/g, (...match: string[]) => `[${match[1]}="${match[2]}"]`);
|
||||||
(match: any /** TODO #9100 */) => `url("${match[2]}")`);
|
|
||||||
css = StringWrapper.replaceAllMapped(
|
|
||||||
css, /\[(.+)=([^"\]]+)\]/g, (match: any /** TODO #9100 */) => `[${match[1]}="${match[2]}"]`);
|
|
||||||
return css;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var _singleTagWhitelist = ['br', 'hr', 'input'];
|
var _singleTagWhitelist = ['br', 'hr', 'input'];
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
import {Injectable, Type} from '@angular/core';
|
import {Injectable, Type} from '@angular/core';
|
||||||
|
|
||||||
import {EventEmitter} from '../../facade/async';
|
import {EventEmitter} from '../../facade/async';
|
||||||
import {StringWrapper, isPresent, print, stringify} from '../../facade/lang';
|
import {isPresent, print, stringify} from '../../facade/lang';
|
||||||
|
|
||||||
import {MessageBus} from './message_bus';
|
import {MessageBus} from './message_bus';
|
||||||
import {Serializer} from './serializer';
|
import {Serializer} from './serializer';
|
||||||
@ -129,10 +129,10 @@ export class ClientMessageBroker_ extends ClientMessageBroker {
|
|||||||
private _handleMessage(message: {[key: string]: any}): void {
|
private _handleMessage(message: {[key: string]: any}): void {
|
||||||
var data = new MessageData(message);
|
var data = new MessageData(message);
|
||||||
// TODO(jteplitz602): replace these strings with messaging constants #3685
|
// TODO(jteplitz602): replace these strings with messaging constants #3685
|
||||||
if (StringWrapper.equals(data.type, 'result') || StringWrapper.equals(data.type, 'error')) {
|
if (data.type === 'result' || data.type === 'error') {
|
||||||
var id = data.id;
|
var id = data.id;
|
||||||
if (this._pending.has(id)) {
|
if (this._pending.has(id)) {
|
||||||
if (StringWrapper.equals(data.type, 'result')) {
|
if (data.type === 'result') {
|
||||||
this._pending.get(id).resolve(data.value);
|
this._pending.get(id).resolve(data.value);
|
||||||
} else {
|
} else {
|
||||||
this._pending.get(id).reject(data.value);
|
this._pending.get(id).reject(data.value);
|
||||||
|
@ -10,7 +10,6 @@ import {LocationChangeListener, PlatformLocation} from '@angular/common';
|
|||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
|
|
||||||
import {EventEmitter} from '../../facade/async';
|
import {EventEmitter} from '../../facade/async';
|
||||||
import {StringWrapper} from '../../facade/lang';
|
|
||||||
import {ClientMessageBroker, ClientMessageBrokerFactory, FnArg, UiArguments} from '../shared/client_message_broker';
|
import {ClientMessageBroker, ClientMessageBrokerFactory, FnArg, UiArguments} from '../shared/client_message_broker';
|
||||||
import {MessageBus} from '../shared/message_bus';
|
import {MessageBus} from '../shared/message_bus';
|
||||||
import {ROUTER_CHANNEL} from '../shared/messaging_api';
|
import {ROUTER_CHANNEL} from '../shared/messaging_api';
|
||||||
@ -38,9 +37,9 @@ export class WebWorkerPlatformLocation extends PlatformLocation {
|
|||||||
var listeners: Array<Function> = null;
|
var listeners: Array<Function> = null;
|
||||||
if (msg.hasOwnProperty('event')) {
|
if (msg.hasOwnProperty('event')) {
|
||||||
let type: string = msg['event']['type'];
|
let type: string = msg['event']['type'];
|
||||||
if (StringWrapper.equals(type, 'popstate')) {
|
if (type === 'popstate') {
|
||||||
listeners = this._popStateListeners;
|
listeners = this._popStateListeners;
|
||||||
} else if (StringWrapper.equals(type, 'hashchange')) {
|
} else if (type === 'hashchange') {
|
||||||
listeners = this._hashChangeListeners;
|
listeners = this._hashChangeListeners;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,8 +269,6 @@ var StringWrapper = {
|
|||||||
|
|
||||||
replaceAllMapped: function(s, from, cb) {
|
replaceAllMapped: function(s, from, cb) {
|
||||||
return s.replace(from, function(matches) {
|
return s.replace(from, function(matches) {
|
||||||
// Remove offset & string from the result array
|
|
||||||
matches.splice(-2, 2);
|
|
||||||
// The callback receives match, p1, ..., pn
|
// The callback receives match, p1, ..., pn
|
||||||
return cb.apply(null, matches);
|
return cb.apply(null, matches);
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import {SelectorMatcher} from '@angular/compiler/src/selector';
|
import {SelectorMatcher} from '@angular/compiler/src/selector';
|
||||||
import {CssSelector} from '@angular/compiler/src/selector';
|
import {CssSelector} from '@angular/compiler/src/selector';
|
||||||
import {Math, StringWrapper} from '@angular/facade/lang';
|
import {Math} from '@angular/facade/lang';
|
||||||
import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_adapter';
|
import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_adapter';
|
||||||
import {bindAction, getIntParameter} from '@angular/testing/src/benchmark_util';
|
import {bindAction, getIntParameter} from '@angular/testing/src/benchmark_util';
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import {ListWrapper, Map, MapWrapper} from '@angular/facade/src/collection';
|
import {ListWrapper, Map, MapWrapper} from '@angular/facade/src/collection';
|
||||||
import {StringWrapper} from '@angular/facade/src/lang';
|
|
||||||
import {Math} from '@angular/facade/src/math';
|
import {Math} from '@angular/facade/src/math';
|
||||||
|
|
||||||
export var ITEMS = 1000;
|
export var ITEMS = 1000;
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import {StringWrapper} from '@angular/facade/src/lang';
|
|
||||||
|
|
||||||
import {AAT_STATUS_LIST, Account, Company, CustomDate, Offering, Opportunity, STATUS_LIST} from './common';
|
import {AAT_STATUS_LIST, Account, Company, CustomDate, Offering, Opportunity, STATUS_LIST} from './common';
|
||||||
|
|
||||||
export function generateOfferings(count: number): Offering[] {
|
export function generateOfferings(count: number): Offering[] {
|
||||||
|
@ -7,8 +7,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {Component, Directive, ElementRef, Injectable, Renderer} from '@angular/core';
|
import {Component, Directive, ElementRef, Injectable, Renderer} from '@angular/core';
|
||||||
import {StringWrapper} from '@angular/core/src/facade/lang';
|
|
||||||
|
|
||||||
|
|
||||||
// A service available to the Injector, used by the HelloCmp component.
|
// A service available to the Injector, used by the HelloCmp component.
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -57,6 +55,6 @@ export class HelloCmp {
|
|||||||
changeGreeting(): void { this.greeting = 'howdy'; }
|
changeGreeting(): void { this.greeting = 'howdy'; }
|
||||||
|
|
||||||
onKeyDown(event: any /** TODO #9100 */): void {
|
onKeyDown(event: any /** TODO #9100 */): void {
|
||||||
this.lastKey = StringWrapper.fromCharCode(event.keyCode);
|
this.lastKey = String.fromCharCode(event.keyCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user