- ivnish Kazakhstan
Automatically closed because Drupal 7 security and bugfix support has ended β as of 5 January 2025. If the issue verifiably applies β to later versions, please reopen with details and update the version.
Greetings to all.
In a simple, non-nested superfish menu that is configured with the "NavBar" menu type (as opposed to the default "Horizontal", which appears to introduce an accordion-styled menu when the screen width becomes too small [i.e., mobile]), the following error might be observed when refreshing any of the site pages:
TypeError: fontsize.attr(...).appendTo(...)[0] is undefined
at line 39 of sites/all/libraries/superfish/supersubs.js
, which is the following line:
.appendTo($$)[0].clientWidth; //clientWidth is faster than width()
It appears, in this case, that the $$
result set does not contain at least one item, is consequently not an array, and the appendTo method is unable to append anything to it (the target). Consequently, the subsequent [0]
reference against it results in undefined
. This raises an exception when the clientWidth
property is invoked on undefined
.
I observed that following snippet of code just a few lines prior to this issue:
// Jump on level if it's a "NavBar"
if ($$.hasClass('sf-navbar')) {
$$ = $$.children('li').children('ul');
}
(I think 'on' in the comment was supposed to read 'one', but that doesn't matter.) Changing it to the following seemed to resolve the issue, but I'm not sure how safe this change is:
// Jump on level if it's a "NavBar"
// if ($$.hasClass('sf-navbar')) {
// $$ = $$.children('li').children('ul');
// }
if ($$.hasClass('sf-navbar') && $$.children('li').children('ul')[0]) {
$$ = $$.children('li').children('ul');
}
I decided to make this change in my local code base because it's obvious $$
needs to contain a query set of at least one element. But please point out any errors in my assumptions, if you'd be so kind.
Many thanks,
Nick
Closed: outdated
2.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Automatically closed because Drupal 7 security and bugfix support has ended β as of 5 January 2025. If the issue verifiably applies β to later versions, please reopen with details and update the version.