fix(core): remove support for Map
/Set
in [class]
/[style]
bindings (#35392)
Close FW-1863 PR Close #35392
This commit is contained in:

committed by
Alex Rickabaugh

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,15 +632,9 @@ 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]);
|
||||
}
|
||||
for (const key in value) {
|
||||
if (value.hasOwnProperty(key)) {
|
||||
keyValueArraySet(styleKeyValueArray, key, value[key]);
|
||||
}
|
||||
}
|
||||
} else if (typeof value === 'string') {
|
||||
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user