@ -1,10 +1,10 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {SafeValue, unwrapSafeValue} from '../../sanitization/bypass';
|
||||
import {stylePropNeedsSanitization, ɵɵsanitizeStyle} from '../../sanitization/sanitization';
|
||||
@ -19,7 +19,7 @@ import {DirectiveDef} from '../interfaces/definition';
|
||||
import {AttributeMarker, TAttributes, TNode, TNodeFlags, TNodeType} from '../interfaces/node';
|
||||
import {RElement, Renderer3} from '../interfaces/renderer';
|
||||
import {SanitizerFn} from '../interfaces/sanitization';
|
||||
import {TStylingKey, TStylingRange, getTStylingRangeNext, getTStylingRangeNextDuplicate, getTStylingRangePrev, getTStylingRangePrevDuplicate} from '../interfaces/styling';
|
||||
import {getTStylingRangeNext, getTStylingRangeNextDuplicate, getTStylingRangePrev, getTStylingRangePrevDuplicate, TStylingKey, TStylingRange} from '../interfaces/styling';
|
||||
import {HEADER_OFFSET, LView, RENDERER, TData, TView} from '../interfaces/view';
|
||||
import {applyStyling} from '../node_manipulation';
|
||||
import {getCurrentDirectiveIndex, getCurrentStyleSanitizer, getLView, getSelectedIndex, getTView, incrementBindingIndex, setCurrentStyleSanitizer} from '../state';
|
||||
@ -27,6 +27,7 @@ import {insertTStylingBinding} from '../styling/style_binding_list';
|
||||
import {getLastParsedKey, getLastParsedValue, parseClassName, parseClassNameNext, parseStyle, parseStyleNext} from '../styling/styling_parser';
|
||||
import {NO_CHANGE} from '../tokens';
|
||||
import {getNativeByIndex} from '../util/view_utils';
|
||||
|
||||
import {setDirectiveInputsWhichShadowsStyling} from './property';
|
||||
|
||||
|
||||
@ -46,7 +47,7 @@ import {setDirectiveInputsWhichShadowsStyling} from './property';
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵstyleSanitizer(sanitizer: StyleSanitizeFn | null): void {
|
||||
export function ɵɵstyleSanitizer(sanitizer: StyleSanitizeFn|null): void {
|
||||
setCurrentStyleSanitizer(sanitizer);
|
||||
}
|
||||
|
||||
@ -72,8 +73,8 @@ export function ɵɵstyleSanitizer(sanitizer: StyleSanitizeFn | null): void {
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵstyleProp(
|
||||
prop: string, value: string | number | SafeValue | undefined | null,
|
||||
suffix?: string | null): typeof ɵɵstyleProp {
|
||||
prop: string, value: string|number|SafeValue|undefined|null,
|
||||
suffix?: string|null): typeof ɵɵstyleProp {
|
||||
checkStylingProperty(prop, value, suffix, false);
|
||||
return ɵɵstyleProp;
|
||||
}
|
||||
@ -93,8 +94,7 @@ export function ɵɵstyleProp(
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵclassProp(
|
||||
className: string, value: boolean | undefined | null): typeof ɵɵclassProp {
|
||||
export function ɵɵclassProp(className: string, value: boolean|undefined|null): typeof ɵɵclassProp {
|
||||
checkStylingProperty(className, value, null, true);
|
||||
return ɵɵclassProp;
|
||||
}
|
||||
@ -119,7 +119,7 @@ export function ɵɵclassProp(
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵstyleMap(styles: {[styleName: string]: any} | string | undefined | null): void {
|
||||
export function ɵɵstyleMap(styles: {[styleName: string]: any}|string|undefined|null): void {
|
||||
checkStylingMap(styleKeyValueArraySet, styleStringParser, styles, false);
|
||||
}
|
||||
|
||||
@ -158,8 +158,8 @@ export function styleStringParser(keyValueArray: KeyValueArray<any>, text: strin
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵclassMap(
|
||||
classes: {[className: string]: boolean | undefined | null} | string | undefined | null): void {
|
||||
export function ɵɵclassMap(classes: {[className: string]: boolean|undefined|null}|string|undefined|
|
||||
null): void {
|
||||
checkStylingMap(keyValueArraySet, classStringParser, classes, true);
|
||||
}
|
||||
|
||||
@ -187,8 +187,8 @@ export function classStringParser(keyValueArray: KeyValueArray<any>, text: strin
|
||||
* @param isClassBased `true` if `class` change (`false` if `style`)
|
||||
*/
|
||||
export function checkStylingProperty(
|
||||
prop: string, value: any | NO_CHANGE,
|
||||
suffixOrSanitizer: SanitizerFn | string | undefined | null, isClassBased: boolean): void {
|
||||
prop: string, value: any|NO_CHANGE, suffixOrSanitizer: SanitizerFn|string|undefined|null,
|
||||
isClassBased: boolean): void {
|
||||
const lView = getLView();
|
||||
const tView = getTView();
|
||||
// Styling instructions use 2 slots per binding.
|
||||
@ -289,14 +289,14 @@ function isInHostBindings(tView: TView, bindingIndex: number): boolean {
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects the necessary information to insert the binding into a linked list of style bindings
|
||||
* using `insertTStylingBinding`.
|
||||
*
|
||||
* @param tView `TView` where the binding linked list will be stored.
|
||||
* @param tStylingKey Property/key of the binding.
|
||||
* @param bindingIndex Index of binding associated with the `prop`
|
||||
* @param isClassBased `true` if `class` change (`false` if `style`)
|
||||
*/
|
||||
* Collects the necessary information to insert the binding into a linked list of style bindings
|
||||
* using `insertTStylingBinding`.
|
||||
*
|
||||
* @param tView `TView` where the binding linked list will be stored.
|
||||
* @param tStylingKey Property/key of the binding.
|
||||
* @param bindingIndex Index of binding associated with the `prop`
|
||||
* @param isClassBased `true` if `class` change (`false` if `style`)
|
||||
*/
|
||||
function stylingFirstUpdatePass(
|
||||
tView: TView, tStylingKey: TStylingKey, bindingIndex: number, isClassBased: boolean): void {
|
||||
ngDevMode && assertFirstUpdatePass(tView);
|
||||
@ -477,9 +477,10 @@ function getTemplateHeadTStylingKey(tData: TData, tNode: TNode, isClassBased: bo
|
||||
function setTemplateHeadTStylingKey(
|
||||
tData: TData, tNode: TNode, isClassBased: boolean, tStylingKey: TStylingKey): void {
|
||||
const bindings = isClassBased ? tNode.classBindings : tNode.styleBindings;
|
||||
ngDevMode && assertNotEqual(
|
||||
getTStylingRangeNext(bindings), 0,
|
||||
'Expecting to have at least one template styling binding.');
|
||||
ngDevMode &&
|
||||
assertNotEqual(
|
||||
getTStylingRangeNext(bindings), 0,
|
||||
'Expecting to have at least one template styling binding.');
|
||||
tData[getTStylingRangePrev(bindings)] = tStylingKey;
|
||||
}
|
||||
|
||||
@ -523,7 +524,7 @@ function collectResidual(tData: TData, tNode: TNode, isClassBased: boolean): Key
|
||||
* @param isClassBased `true` if `class` (`false` if `style`)
|
||||
*/
|
||||
function collectStylingFromDirectives(
|
||||
hostDirectiveDef: DirectiveDef<any>| null, tData: TData, tNode: TNode, stylingKey: TStylingKey,
|
||||
hostDirectiveDef: DirectiveDef<any>|null, tData: TData, tNode: TNode, stylingKey: TStylingKey,
|
||||
isClassBased: boolean): TStylingKey {
|
||||
// We need to loop because there can be directives which have `hostAttrs` but don't have
|
||||
// `hostBindings` so this loop catches up to the current directive..
|
||||
@ -559,7 +560,7 @@ function collectStylingFromDirectives(
|
||||
* @param isClassBased `true` if `class` (`false` if `style`)
|
||||
*/
|
||||
function collectStylingFromTAttrs(
|
||||
stylingKey: TStylingKey | undefined, attrs: TAttributes | null,
|
||||
stylingKey: TStylingKey|undefined, attrs: TAttributes|null,
|
||||
isClassBased: boolean): TStylingKey {
|
||||
const desiredMarker = isClassBased ? AttributeMarker.Classes : AttributeMarker.Styles;
|
||||
let currentMarker = AttributeMarker.ImplicitAttributes;
|
||||
@ -711,7 +712,7 @@ function updateStylingMap(
|
||||
setKey = newKey;
|
||||
setValue = newValue;
|
||||
}
|
||||
} else if (newKey === null || oldKey !== null && oldKey < newKey !) {
|
||||
} else if (newKey === null || oldKey !== null && oldKey < newKey!) {
|
||||
// DELETE: oldKey key is missing or we did not find the oldKey in the newValue
|
||||
// (because the keyValueArray is sorted and `newKey` is found later alphabetically).
|
||||
// `"background" < "color"` so we need to delete `"background"` because it is not found in the
|
||||
@ -754,7 +755,7 @@ function updateStylingMap(
|
||||
*/
|
||||
function updateStyling(
|
||||
tView: TView, tNode: TNode, lView: LView, renderer: Renderer3, prop: string,
|
||||
value: string | undefined | null | boolean, isClassBased: boolean, bindingIndex: number) {
|
||||
value: string|undefined|null|boolean, isClassBased: boolean, bindingIndex: number) {
|
||||
if (tNode.type !== TNodeType.Element) {
|
||||
// It is possible to have styling on non-elements (such as ng-container).
|
||||
// This is rare, but it does happen. In such a case, just ignore the binding.
|
||||
@ -811,7 +812,7 @@ function updateStyling(
|
||||
* @param isClassBased `true` if `class` (`false` if `style`)
|
||||
*/
|
||||
function findStylingValue(
|
||||
tData: TData, tNode: TNode | null, lView: LView, prop: string, index: number,
|
||||
tData: TData, tNode: TNode|null, lView: LView, prop: string, index: number,
|
||||
isClassBased: boolean): any {
|
||||
// `TNode` to use for resolving static styling. Also controls search direction.
|
||||
// - `TNode` search next and quit as soon as `isStylingValuePresent(value)` is true.
|
||||
@ -856,7 +857,7 @@ function findStylingValue(
|
||||
// consult residual styling
|
||||
let residual = isClassBased ? tNode.residualClasses : tNode.residualStyles;
|
||||
if (residual != null /** OR residual !=== undefined */) {
|
||||
value = keyValueArrayGet(residual !, prop);
|
||||
value = keyValueArrayGet(residual!, prop);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
@ -884,7 +885,7 @@ function isStylingValuePresent(value: any): boolean {
|
||||
* @param suffixOrSanitizer
|
||||
*/
|
||||
function normalizeAndApplySuffixOrSanitizer(
|
||||
value: any, suffixOrSanitizer: SanitizerFn | string | undefined | null): string|null|undefined|
|
||||
value: any, suffixOrSanitizer: SanitizerFn|string|undefined|null): string|null|undefined|
|
||||
boolean {
|
||||
if (value == null /** || value === undefined */) {
|
||||
// do nothing
|
||||
|
Reference in New Issue
Block a user