this._objects.get(objectId).forEach(function(elementData) {
var summaryList = elBySel(this._options.summaryListSelector, elementData.element);
+ // summary list for the object not found; abort
+ if (summaryList === null) return;
+
var sortedElements = {}, elements = elBySelAll('li', summaryList);
for (var i = 0, length = elements.length; i < length; i++) {
if (data[elData(elements[i], 'reaction-type-id')] !== undefined) {
_updateReactButton: function(objectID, reactionTypeID) {
this._objects.get(objectID).forEach(function (elementData) {
- if (reactionTypeID) {
- elementData.reactButton.classList.add('active');
- elData(elementData.reactButton, 'reaction-type-id', reactionTypeID);
- }
- else {
- elData(elementData.reactButton, 'reaction-type-id', 0);
- elementData.reactButton.classList.remove('active');
+ if (elementData.reactButton !== null) {
+ if (reactionTypeID) {
+ elementData.reactButton.classList.add('active');
+ elData(elementData.reactButton, 'reaction-type-id', reactionTypeID);
+ } else {
+ elData(elementData.reactButton, 'reaction-type-id', 0);
+ elementData.reactButton.classList.remove('active');
+ }
}
});
},
_markReactionAsActive: function() {
- var reactionTypeID = elData(this._objects.get(this._popoverCurrentObjectId)[0].reactButton, 'reaction-type-id');
+ var reactionTypeID;
+ this._objects.get(this._popoverCurrentObjectId).forEach(function (element) {
+ if (element.reactButton !== null) {
+ reactionTypeID = elData(element.reactButton, 'reaction-type-id');
+ }
+ });
+
+ if (reactionTypeID === undefined) {
+ throw new Error("Unable to find react button for current popover.");
+ }
// clear old active state
var elements = elBySelAll('.reactionTypeButton.active', this._getPopover());