refactor: remove some facades (#12335)
This commit is contained in:

committed by
Alex Rickabaugh

parent
0ecd9b2df0
commit
76dd026447
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import {Inject, Injectable, RenderComponentType, Renderer, RootRenderer, ViewEncapsulation} from '@angular/core';
|
||||
import {Json, isArray, isBlank, isPresent, isString, stringify} from '../facade/lang';
|
||||
import {isBlank, isPresent, stringify} from '../facade/lang';
|
||||
import {AnimationKeyframe, AnimationPlayer, AnimationStyles, RenderDebugInfo} from '../private_import_core';
|
||||
|
||||
import {AnimationDriver} from './animation_driver';
|
||||
@ -74,7 +74,7 @@ export class DomRenderer implements Renderer {
|
||||
|
||||
selectRootElement(selectorOrNode: string|any, debugInfo: RenderDebugInfo): Element {
|
||||
var el: any /** TODO #9100 */;
|
||||
if (isString(selectorOrNode)) {
|
||||
if (typeof selectorOrNode === 'string') {
|
||||
el = getDOM().querySelector(this._rootRenderer.document, selectorOrNode);
|
||||
if (isBlank(el)) {
|
||||
throw new Error(`The selector "${selectorOrNode}" did not match any elements`);
|
||||
@ -194,10 +194,11 @@ export class DomRenderer implements Renderer {
|
||||
if (getDOM().isCommentNode(renderElement)) {
|
||||
const existingBindings =
|
||||
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;
|
||||
getDOM().setText(
|
||||
renderElement, TEMPLATE_COMMENT_TEXT.replace('{}', Json.stringify(parsedBindings)));
|
||||
renderElement,
|
||||
TEMPLATE_COMMENT_TEXT.replace('{}', JSON.stringify(parsedBindings, null, 2)));
|
||||
} else {
|
||||
this.setElementAttribute(renderElement, propertyName, propertyValue);
|
||||
}
|
||||
@ -279,9 +280,10 @@ function _shimHostAttribute(componentShortId: string): string {
|
||||
}
|
||||
|
||||
function _flattenStyles(compId: string, styles: Array<any|any[]>, target: string[]): string[] {
|
||||
for (var i = 0; i < styles.length; i++) {
|
||||
var style = styles[i];
|
||||
if (isArray(style)) {
|
||||
for (let i = 0; i < styles.length; i++) {
|
||||
let style = styles[i];
|
||||
|
||||
if (Array.isArray(style)) {
|
||||
_flattenStyles(compId, style, target);
|
||||
} else {
|
||||
style = style.replace(COMPONENT_REGEX, compId);
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import {AUTO_STYLE} from '@angular/core';
|
||||
|
||||
import {isNumber, isPresent} from '../facade/lang';
|
||||
import {isPresent} from '../facade/lang';
|
||||
import {AnimationKeyframe, AnimationStyles} from '../private_import_core';
|
||||
|
||||
import {AnimationDriver} from './animation_driver';
|
||||
@ -83,7 +83,7 @@ function _resolveStyleUnit(
|
||||
val: string | number, userProvidedProp: string, formattedProp: string): string {
|
||||
var unit = '';
|
||||
if (_isPixelDimensionStyle(formattedProp) && val != 0 && val != '0') {
|
||||
if (isNumber(val)) {
|
||||
if (typeof val === 'number') {
|
||||
unit = 'px';
|
||||
} else if (_findDimensionalSuffix(val.toString()).length == 0) {
|
||||
throw new Error('Please provide a CSS unit value for ' + userProvidedProp + ':' + val);
|
||||
|
Reference in New Issue
Block a user