From 6aa2de51511bf847f6e69dfcfc9e7d977ef171a6 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Wed, 25 Nov 2009 01:45:15 +0100 Subject: [PATCH] gitweb.js: Harden setting blamed commit info in incremental blame Internet Explorer 8 stops at beginning of blame filling with the following bug: "firstChild is null or not an object" at this line: a_sha1.firstChild.data = commit.sha1.substr(0, 8); It is (probably) caused by the fact that while a_sha1 element, which looks like this: It has a firstChild which is a text node containing only whitespace (single space character) in other web browsers (Firefox 3.5, Opera 10, Google Chrome 3.0), IE8 clobbers DOM, removing trailing/leading whitespace. Protect against this bug by creating text element if it does not exist. Found-by: Stephen Boyd Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- gitweb/gitweb.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gitweb/gitweb.js b/gitweb/gitweb.js index f1ba9ae52b..5292c37d2c 100644 --- a/gitweb/gitweb.js +++ b/gitweb/gitweb.js @@ -562,7 +562,12 @@ function handleLine(commit, group) { td_sha1.rowSpan = group.numlines; a_sha1.href = projectUrl + 'a=commit;h=' + commit.sha1; - a_sha1.firstChild.data = commit.sha1.substr(0, 8); + if (a_sha1.firstChild) { + a_sha1.firstChild.data = commit.sha1.substr(0, 8); + } else { + a_sha1.appendChild( + document.createTextNode(commit.sha1.substr(0, 8))); + } if (group.numlines >= 2) { var fragment = document.createDocumentFragment(); var br = document.createElement("br"); -- 2.11.4.GIT