refactor(RegExpWrapper): remove the facade (#10512)

This commit is contained in:
Jason Choi
2016-08-05 09:50:49 -07:00
committed by Alex Rickabaugh
parent b4613ab2d2
commit 83e2d3d1cb
31 changed files with 112 additions and 194 deletions

View File

@ -10,7 +10,7 @@ import {Inject, Injectable, OpaqueToken, RenderComponentType, Renderer, RootRend
import {StringMapWrapper} from '../facade/collection';
import {BaseException} from '../facade/exceptions';
import {Json, RegExpWrapper, StringWrapper, isArray, isBlank, isPresent, isString, stringify} from '../facade/lang';
import {Json, StringWrapper, isArray, isBlank, isPresent, isString, stringify} from '../facade/lang';
import {DomSharedStylesHost} from './shared_styles_host';
@ -28,7 +28,7 @@ const NAMESPACE_URIS = {
'xhtml': 'http://www.w3.org/1999/xhtml'
};
const TEMPLATE_COMMENT_TEXT = 'template bindings={}';
var TEMPLATE_BINDINGS_EXP = /^template bindings=(.*)$/g;
var TEMPLATE_BINDINGS_EXP = /^template bindings=(.*)$/;
export abstract class DomRootRenderer implements RootRenderer {
protected registeredComponents: Map<string, DomRenderer> = new Map<string, DomRenderer>();
@ -197,9 +197,8 @@ export class DomRenderer implements Renderer {
setBindingDebugInfo(renderElement: any, propertyName: string, propertyValue: string): void {
var dashCasedPropertyName = camelCaseToDashCase(propertyName);
if (getDOM().isCommentNode(renderElement)) {
var existingBindings = RegExpWrapper.firstMatch(
TEMPLATE_BINDINGS_EXP,
StringWrapper.replaceAll(getDOM().getText(renderElement), /\n/g, ''));
const existingBindings = StringWrapper.replaceAll(getDOM().getText(renderElement), /\n/g, '')
.match(TEMPLATE_BINDINGS_EXP);
var parsedBindings = Json.parse(existingBindings[1]);
(parsedBindings as any /** TODO #9100 */)[dashCasedPropertyName] = propertyValue;
getDOM().setText(
@ -298,12 +297,12 @@ function _flattenStyles(compId: string, styles: Array<any|any[]>, target: string
return target;
}
var NS_PREFIX_RE = /^:([^:]+):(.+)/g;
const NS_PREFIX_RE = /^:([^:]+):(.+)$/;
function splitNamespace(name: string): string[] {
if (name[0] != ':') {
return [null, name];
}
let match = RegExpWrapper.firstMatch(NS_PREFIX_RE, name);
const match = name.match(NS_PREFIX_RE);
return [match[1], match[2]];
}

View File

@ -86,7 +86,7 @@ export function sanitizeStyle(value: string): string {
// Single url(...) values are supported, but only for URLs that sanitize cleanly. See above for
// reasoning behind this.
let urlMatch = URL_RE.exec(value);
const urlMatch = value.match(URL_RE);
if ((urlMatch && sanitizeUrl(urlMatch[1]) === urlMatch[1]) ||
value.match(SAFE_STYLE_VALUE) && hasBalancedQuotes(value)) {
return value; // Safe style values.