Potential bug in handling of updates for widgets
imeckler opened this issue · 1 comments
imeckler commented
This is in reference to the code here. Namely,
function updateWidget(a, b) {
if (isWidget(a) && isWidget(b)) {
if ("name" in a && "name" in b) {
return a.id === b.id
} else {
return a.init === b.init
}
}
return false
}
It seems strange that it is checking for the mere presence of a field called name
and then checking equality of the id
fields. I would imagine the intent is more like
function updateWidget(a, b) {
if (isWidget(a) && isWidget(b)) {
if ("id" in a && "id" in b) {
return a.id === b.id
} else {
return a.init === b.init
}
}
return false
}
aameen951 commented
Yes, I think this is a bug.
I feel like it should even be:
...
if ("key" in a && "key" in b) {
return a.key === b.key
} else {
return a.init === b.init
}
...