[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#774808: debsources: line number undefined



Hello again.

I was wrong in my previous email, the code I mentionned is not the cause
of the bug in question. It was an error that I did not catch when
testing with Firefox.

Matthieu, can you test the attached patch and see if it fixes the issue
for you?

Cheers

Jason
>From 181b7b6e6f57966b534f352c61a8e7cc81572b7d Mon Sep 17 00:00:00 2001
From: Jason Pleau <jason@jpleau.ca>
Date: Thu, 8 Jan 2015 22:51:43 -0500
Subject: [PATCH] web app: fix 'undefined' line numbers in source code pages

Problem: In Iceweasel / Firefox, clicking on a line-number when browsing
a source file caused the line number returned to be "undefined", and
so "#Lundefined" appeared in the URL.

The cause was that to retrieve the line numbers from the <a> elements we
clicked on, I was using .innerText, which is not supported by Firefox /
Iceweasel. The alternative is using .textContent.

The solution was to use "element.textContent || element.innerText", so
that it works browsers that support either .textContent or .innerText.

Closes #774808
---
 debsources/app/static/javascript/debsources.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/debsources/app/static/javascript/debsources.js b/debsources/app/static/javascript/debsources.js
index 6c8d2ee..844e58a 100644
--- a/debsources/app/static/javascript/debsources.js
+++ b/debsources/app/static/javascript/debsources.js
@@ -115,10 +115,10 @@ var debsources = function(message_pos) {
 
         if (!event.shiftKey || !last_clicked) {
             last_clicked = callerElement;
-            change_hash_without_scroll(callerElement, "L" + callerElement.innerText);
+            change_hash_without_scroll(callerElement, "L" + (callerElement.textContent || callerElement.innerText));
         } else {
-            var first_line = parseInt(last_clicked.innerText);
-            var second_line = parseInt(callerElement.innerText);
+            var first_line = parseInt(last_clicked.textContent || last_clicked.innerText);
+            var second_line = parseInt(callerElement.textContent || callerElement.innerText);
 
             if (second_line < first_line) {
                 var tmp = first_line;
-- 
2.1.4


Reply to: