Added support for ES6 Maps to Utils.areObjectsEqual
Этот коммит содержится в:
@@ -392,6 +392,10 @@ export function areObjectsEqual(x, y) {
|
||||
return x.toString() === y.toString();
|
||||
}
|
||||
|
||||
if (x instanceof Map && y instanceof Map) {
|
||||
return areMapsEqual(x, y);
|
||||
}
|
||||
|
||||
// At last checking prototypes as good a we can
|
||||
if (!(x instanceof Object && y instanceof Object)) {
|
||||
return false;
|
||||
@@ -456,6 +460,24 @@ export function areObjectsEqual(x, y) {
|
||||
return true;
|
||||
}
|
||||
|
||||
export function areMapsEqual(a, b) {
|
||||
if (a.size !== b.size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const [key, value] of a) {
|
||||
if (!b.has(key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!areObjectsEqual(value, b.get(key))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export function replaceHtmlEntities(text) {
|
||||
var tagsToReplace = {
|
||||
'&': '&',
|
||||
|
||||
Ссылка в новой задаче
Block a user