]> Lady’s Gitweb - Gitweb/commitdiff
gitweb.js: Harden setting blamed commit info in incremental blame
authorJakub Narebski <redacted>
Wed, 25 Nov 2009 00:45:15 +0000 (01:45 +0100)
committerLady <redacted>
Mon, 6 Apr 2026 04:50:39 +0000 (00:50 -0400)
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:

  <a href=""> </a>

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 <redacted>
Signed-off-by: Jakub Narebski <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.js

index 1b0d1f98bc41e339031faf94eade3e778b38d6b5a74bb11cb0b136a9ab801300..ff2d53365b02fd70522a8fcef202dbda902aeb09b31a5da592fab457167e28f4 100644 (file)
--- a/gitweb.js
+++ b/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");
This page took 0.155845 seconds and 4 git commands to generate.