Hi,

The following piece of code in tableheader.js causes javascript error $("td" + location.hash).offset() is undefined when a hash is present in the URL that has no relation with table cells.

      if (prevAnchor != location.hash) {
        if (location.hash != '') {
          var scrollLocation = $('td' + location.hash).offset().top - $(e).height();
          $('body, html').scrollTop(scrollLocation);
        }
        prevAnchor = location.hash;
      }

The error happens when the selector 'td' + location.hash does not match any element. In that case, offset().top is undefined.

I think it could be fixed by adding a condition like this:

      if (prevAnchor != location.hash) {
        if (location.hash != '' && $('td' + location.hash).size()) {
          var scrollLocation = $('td' + location.hash).offset().top - $(e).height();
          $('body, html').scrollTop(scrollLocation);
        }
        prevAnchor = location.hash;
      }

I'm making the issue critical because this issue causes javascript errors when a hash is present in the URL that does not match a TD identifier. This javascript error breaks all the javascript present in the site, including ads, analytics, etc.

Please, consider backporting this fix to D6 too.

Comments

markus_petrux’s picture

Version: 6.x-dev » 7.x-dev
Status: Active » Needs review
Issue tags: +JavaScript
StatusFileSize
new775 bytes

I guess this probably needs to be fixed first in dev. Attached patch against HEAD.

Status: Needs review » Needs work

The last submitted patch failed testing.

markus_petrux’s picture

Status: Needs work » Needs review
StatusFileSize
new811 bytes

wow! and now? Why the patch failed?

hmm... adding -p option to the diff command to see if that helps.

Status: Needs review » Needs work

The last submitted patch failed testing.

markus_petrux’s picture

hmm... this is kind of frustrating, isn't it? All you can see here is that the patch fails, but it doesn't tell you why.

I hate to turn this into a support question, but can someone drive me in the correct direction?

markus_petrux’s picture

Status: Needs work » Closed (duplicate)