Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Hallo, an issue turned up in my queue that exposed a bug in Superfish. Here's the fix: #2330001-5: Custom build conflicting with other javascript
The problem ended up being that there's a line of JS in superfish which checks for Modernizr then assumes that Modernizr.mq()
is present. It doesn't always have to be there if someone uses a custom build, so you have to specifically check for that function before invoking it; simply checking for the global Modernizr
object is not sufficient. Here's an example:
// See a very simple example at http://jsbin.com/kedifiyatuko/1/edit
if (typeof Modernizr.mq === 'function') {
// use Modernizr.mq('max-width:' + (breakpoint - 1))
}
else {
// can't use it if Modernizr.mq === 'undefined'
}
Comment | File | Size | Author |
---|---|---|---|
#4 | 2331593-4-superfish-Check_for_Modernizr.mq_before_usage.patch | 3.06 KB | grndlvl |
Comments
Comment #1
bneil CreditAttribution: bneil commentedHere's a pull request to change it in the Superfish library: https://github.com/mehrpadin/Superfish-for-Drupal/pull/4
Comment #2
ruplThanks for the quick turnaround! I left my +1 in the PR.
Comment #3
adam-delaney CreditAttribution: adam-delaney commentedI have found an issue relating to site's that do not use the Modernizr library or do not detect for media queries breaking other javascript because the Modernizr object is undefined. I have created a pull request change in the Superfish library for Drupal that resolves the issue. https://github.com/mehrpadin/Superfish-for-Drupal/pull/6
Comment #4
grndlvl CreditAttribution: grndlvl commentedFor those that need a patch
Comment #5
rcodina CreditAttribution: rcodina commentedPatch on #4 works for me, but I had to apply it manually. I only applied it to sfsmallscreen.js because it was the only error that was annoying me. Thanks for this.
Comment #6
mehrpadin CreditAttribution: mehrpadin commentedThanks.
For the record: Merged back then.