From 01350d7f6d66796ac0f18d6ab3582cd60f2525c5 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Fri, 2 May 2014 14:20:37 +0800 Subject: Bug 1004229: "TypeError: lastCommentDiv.parentNode is null" from inline history when the last comment is a 'duplicate' comment --- extensions/InlineHistory/web/inline-history.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'extensions/InlineHistory') diff --git a/extensions/InlineHistory/web/inline-history.js b/extensions/InlineHistory/web/inline-history.js index c59c2932c..685798ec0 100644 --- a/extensions/InlineHistory/web/inline-history.js +++ b/extensions/InlineHistory/web/inline-history.js @@ -34,6 +34,7 @@ var inline_history = { dupeId = match[1]; // remove the element comment.parentNode.removeChild(comment); + comments[i] = false; // update the html for the history item to include the comment number if (dupeId == 0) continue; @@ -52,6 +53,8 @@ var inline_history = { } } } + if (!comments[i]) + continue; // remove 'Additional hours worked: ' comments var commentNodes = comments[i].childNodes; @@ -65,6 +68,14 @@ var inline_history = { } } + // remove deleted comments + for (var i = 0; i < comments.length; i++) { + if (!comments[i]) { + comments.splice(i, 1); + i--; + } + } + // ensure new items are placed immediately after the last comment if (!comments.length) return; var lastCommentDiv = comments[comments.length - 1]; -- cgit v1.2.3-24-g4f1b