Bug 720981 - Remove element.iQEventData when it's empty. r=ttaubert

This commit is contained in:
Dão Gottwald 2012-01-25 13:40:11 +01:00
Родитель eae83ede2d
Коммит 894f5e0fe4
1 изменённых файлов: 8 добавлений и 3 удалений

Просмотреть файл

@ -741,6 +741,11 @@ iQClass.prototype = {
if (pair.original == func) { if (pair.original == func) {
handler = pair.modified; handler = pair.modified;
elem.iQEventData[type].splice(a, 1); elem.iQEventData[type].splice(a, 1);
if (!elem.iQEventData[type].length) {
delete elem.iQEventData[type];
if (!Object.keys(elem.iQEventData).length)
delete elem.iQEventData;
}
break; break;
} }
} }
@ -765,10 +770,10 @@ iQClass.prototype = {
if (!elem.iQEventData) if (!elem.iQEventData)
continue; continue;
for (let type in elem.iQEventData) { Object.keys(elem.iQEventData).forEach(function (type) {
while (elem.iQEventData[type].length) while (elem.iQEventData && elem.iQEventData[type])
this.unbind(type, elem.iQEventData[type][0].original); this.unbind(type, elem.iQEventData[type][0].original);
} }, this);
} }
return this; return this;