Variables: Fixes maximum call stack bug for empty value (#25503)
This commit is contained in:
@@ -12,4 +12,32 @@ describe('when checking template variables', () => {
|
|||||||
expect(findTemplateVarChanges(b, a)).toEqual({ 'var-xyz': 'hello' });
|
expect(findTemplateVarChanges(b, a)).toEqual({ 'var-xyz': 'hello' });
|
||||||
expect(findTemplateVarChanges(a, b)).toEqual({ 'var-xyz': '' });
|
expect(findTemplateVarChanges(a, b)).toEqual({ 'var-xyz': '' });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('then should ignore equal values', () => {
|
||||||
|
const a: UrlQueryMap = {
|
||||||
|
'var-xyz': 'hello',
|
||||||
|
bbb: 'ignore me',
|
||||||
|
};
|
||||||
|
const b: UrlQueryMap = {
|
||||||
|
'var-xyz': 'hello',
|
||||||
|
aaa: 'ignore me',
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(findTemplateVarChanges(b, a)).toBeUndefined();
|
||||||
|
expect(findTemplateVarChanges(a, b)).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('then should ignore equal values with empty values', () => {
|
||||||
|
const a: UrlQueryMap = {
|
||||||
|
'var-xyz': '',
|
||||||
|
bbb: 'ignore me',
|
||||||
|
};
|
||||||
|
const b: UrlQueryMap = {
|
||||||
|
'var-xyz': '',
|
||||||
|
aaa: 'ignore me',
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(findTemplateVarChanges(b, a)).toBeUndefined();
|
||||||
|
expect(findTemplateVarChanges(a, b)).toBeUndefined();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ export function findTemplateVarChanges(query: UrlQueryMap, old: UrlQueryMap): Ur
|
|||||||
if (!key.startsWith('var-')) {
|
if (!key.startsWith('var-')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!query[key]) {
|
if (!query.hasOwnProperty(key)) {
|
||||||
changes[key] = ''; // removed
|
changes[key] = ''; // removed
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user