Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
IE7 (I know) is complaining about incorrect syntax created by the modernizr module. It's only a single comma. This output should not have a comma after the js file name.
<script>Modernizr.load([{
test: Modernizr.mq('only all'),
nope: '/sites/all/themes/mytheme/javascripts/respond.min.js',
}]);</script>
I think this patch is the correct fix, but please review.
Comment | File | Size | Author |
---|---|---|---|
#12 | 1923498-12-trailing-comma.patch | 412 bytes | rupl |
#11 | modernizr-js-syntax-11.patch | 2.09 KB | ibullock |
#8 | modernizr-js-syntax.patch | 1.56 KB | ibullock |
modernizr-js-syntax.patch | 636 bytes | marcvangend | |
Comments
Comment #1
ruplThanks for the report! You're correct, the trailing comma makes older browsers choke.
We can't just remove the comma from any single line, because someone may choose to add a
callback
orcomplete
function, and in that case those are the lines which need the comma removed.The correct approach (other than re-writing this to fix the overall architecture) is to remove that last comma after the entire command has been built.
I thought this was handled properly (line 368 in modernizr.module at the time of comment), but your report indicates that it doesn't.
Comment #2
ruplAs a sidenote, I would advise you to load respond.js directly using the following syntax that avoids an asynchronous download:
This advice is straight from the Modernizr devs.
Comment #3
marcvangendThanks for the quick reaction and the tip. I don't know enough about all possible options, callbacks etc. to write a new patch, but I'd be happy to test one.
Comment #4
ibullockPatch excludes some required commas. See snippet below. I'm working on my own fix and will post if I find something flexible enough :S
Comment #5
ibullockHere's what I've ended up changing that same block to (starts at line 333 in 7.x-3.1):
Comment #6
ruplHello, thanks for tracking down the problem. Do you know how to make a patch? I can't really spot the difference in the code you supplied, but if you created a patch I would be able to review/commit the fix much faster.
Comment #7
ibullockWas planing on working on a patch this week anyway. I'll get it up asap.
Comment #8
ibullockHere's the patch. It basically adds the commas as a prefix rather than appending them. I had to move a few linebreaks as well to keep the formatting.
Comment #9
ibullockComment #10
marcvangendI didn't test the patch yet, but two remarks:
This line has trailing spaces.
If you're using prefixed instead of suffixed comma's, doesn't this become redundant?
Comment #11
ibullockRerolled.
Comment #12
ruplk I looked into this, pretty simple fix based on a silly error of mine. I'm adding some newlines into the output just for readability's sake, and the substr() mentioned in comment #1 needs to remove two characters instead of one to account for both the comma and newline.
Would you mind trying this patch?
Comment #13
ibullockDid a quick test. Seems to be working for me.
Comment #14
ruplThat's close enough to an RTBC for me ;)
fixed!
Comment #16
jtwalters CreditAttribution: jtwalters commentedNeeds work because a single resource has the same bug...
Should look like this:
Comment #17
ruplCan I get a patch to review and commit?
Comment #18
jtwalters CreditAttribution: jtwalters commentedIt appears that the latest dev did indeed solve the issue. Sorry about that. I was using 7.x-3.1 + a patch I found here in the issue queue.