fix(core): remove support for Map
/Set
in [class]
/[style]
bindings (#35392)
Close FW-1863 PR Close #35392
This commit is contained in:
parent
5576031b44
commit
2ca7984d55
@ -119,9 +119,7 @@ export function ɵɵclassProp(
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵstyleMap(
|
||||
styles: {[styleName: string]: any} | Map<string, string|number|null|undefined>| string |
|
||||
undefined | null): void {
|
||||
export function ɵɵstyleMap(styles: {[styleName: string]: any} | string | undefined | null): void {
|
||||
checkStylingMap(styleKeyValueArraySet, styleStringParser, styles, false);
|
||||
}
|
||||
|
||||
@ -161,8 +159,7 @@ export function styleStringParser(keyValueArray: KeyValueArray<any>, text: strin
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵclassMap(
|
||||
classes: {[className: string]: boolean | undefined | null} |
|
||||
Map<string, boolean|undefined|null>| Set<string>| string[] | string | undefined | null): void {
|
||||
classes: {[className: string]: boolean | undefined | null} | string | undefined | null): void {
|
||||
checkStylingMap(keyValueArraySet, classStringParser, classes, true);
|
||||
}
|
||||
|
||||
@ -626,8 +623,8 @@ export function getHostDirectiveDef(tData: TData): DirectiveDef<any>|null {
|
||||
*/
|
||||
export function toStylingKeyValueArray(
|
||||
keyValueArraySet: (keyValueArray: KeyValueArray<any>, key: string, value: any) => void,
|
||||
stringParser: (styleKeyValueArray: KeyValueArray<any>, text: string) => void, value: string|
|
||||
string[]|{[key: string]: any}|Map<any, any>|Set<any>|null|undefined): KeyValueArray<any> {
|
||||
stringParser: (styleKeyValueArray: KeyValueArray<any>, text: string) => void,
|
||||
value: string|string[]|{[key: string]: any}|null|undefined): KeyValueArray<any> {
|
||||
if (value == null /*|| value === undefined */ || value === '') return EMPTY_ARRAY as any;
|
||||
const styleKeyValueArray: KeyValueArray<any> = [] as any;
|
||||
if (Array.isArray(value)) {
|
||||
@ -635,17 +632,11 @@ export function toStylingKeyValueArray(
|
||||
keyValueArraySet(styleKeyValueArray, value[i], true);
|
||||
}
|
||||
} else if (typeof value === 'object') {
|
||||
if (value instanceof Map) {
|
||||
value.forEach((v, k) => keyValueArraySet(styleKeyValueArray, k, v));
|
||||
} else if (value instanceof Set) {
|
||||
value.forEach((k) => keyValueArraySet(styleKeyValueArray, k, true));
|
||||
} else {
|
||||
for (const key in value) {
|
||||
if (value.hasOwnProperty(key)) {
|
||||
keyValueArraySet(styleKeyValueArray, key, value[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (typeof value === 'string') {
|
||||
stringParser(styleKeyValueArray, value);
|
||||
} else {
|
||||
@ -674,11 +665,10 @@ function styleKeyValueArraySet(keyValueArray: KeyValueArray<any>, key: string, v
|
||||
* Update map based styling.
|
||||
*
|
||||
* Map based styling could be anything which contains more than one binding. For example `string`,
|
||||
* `Map`, `Set` or object literal. Dealing with all of these types would complicate the logic so
|
||||
* or object literal. Dealing with all of these types would complicate the logic so
|
||||
* instead this function expects that the complex input is first converted into normalized
|
||||
* `KeyValueArray`. The advantage of normalization is that we get the values sorted, which makes it
|
||||
* very
|
||||
* cheap to compute deltas between the previous and current value.
|
||||
* very cheap to compute deltas between the previous and current value.
|
||||
*
|
||||
* @param tView Associated `TView.data` contains the linked list of binding priorities.
|
||||
* @param tNode `TNode` where the binding is located.
|
||||
|
@ -440,19 +440,6 @@ describe('styling', () => {
|
||||
] as any);
|
||||
});
|
||||
});
|
||||
describe('Map', () => {
|
||||
it('should parse', () => {
|
||||
expect(toStylingKeyValueArray(
|
||||
keyValueArraySet, null !, new Map<string, string>([['X', 'x'], ['A', 'a']])))
|
||||
.toEqual(['A', 'a', 'X', 'x'] as any);
|
||||
});
|
||||
});
|
||||
describe('Iterable', () => {
|
||||
it('should parse', () => {
|
||||
expect(toStylingKeyValueArray(keyValueArraySet, null !, new Set<string>(['X', 'A'])))
|
||||
.toEqual(['A', true, 'X', true] as any);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
4
tools/public_api_guard/core/core.d.ts
vendored
4
tools/public_api_guard/core/core.d.ts
vendored
@ -704,7 +704,7 @@ export declare function ɵɵattributeInterpolateV(attrName: string, values: any[
|
||||
|
||||
export declare function ɵɵclassMap(classes: {
|
||||
[className: string]: boolean | undefined | null;
|
||||
} | Map<string, boolean | undefined | null> | Set<string> | string[] | string | undefined | null): void;
|
||||
} | string | undefined | null): void;
|
||||
|
||||
export declare function ɵɵclassMapInterpolate1(prefix: string, v0: any, suffix: string): void;
|
||||
|
||||
@ -1035,7 +1035,7 @@ export declare function ɵɵstaticViewQuery<T>(predicate: Type<any> | string[],
|
||||
|
||||
export declare function ɵɵstyleMap(styles: {
|
||||
[styleName: string]: any;
|
||||
} | Map<string, string | number | null | undefined> | string | undefined | null): void;
|
||||
} | string | undefined | null): void;
|
||||
|
||||
export declare function ɵɵstyleProp(prop: string, value: string | number | SafeValue | undefined | null, suffix?: string | null): typeof ɵɵstyleProp;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user