There is a problem with line 67 in file js/base.js
var pair = pairs[i].split('=');
variable pairs[i] sometimes contain functions and under Chrome appear fatal error, so I dont` how come functions can be in this array but I`ve fixed code into
if(typeof(pairs[i]) == 'string'){
var pair = pairs[i].split('=');
// Ignore the 'q' path argument, if present.
if (pair[0] != 'q' && pair[1]) {
args[pair[0]] = decodeURIComponent(pair[1].replace(/\+/g, ' '));
}
} else if (typeof(pairs[i]) == 'function') {
eval(pairs[i]);
}
And now it works fine.
Is there anybody who also saw error like this? This problem appeared after I`ve updated views to latest version (2.10)
| Comment | File | Size | Author |
|---|---|---|---|
| #26 | views-6.x-2.11-798764_3.patch | 396 bytes | jm.federico |
| #25 | 798764-2-views-base.js_.patch | 626 bytes | ChrisRut |
| #24 | js-error_views.png | 42.01 KB | ChrisRut |
| #24 | 798764-views-base.js_.patch | 436 bytes | ChrisRut |
| #4 | views.base_.js_.patch | 755 bytes | setvik |
Comments
Comment #1
mikedance commentedI am receiving this error as well, luckily I found this issue!
Comment #2
dawehnerCould you please make a real patch out of it?
Comment #3
migueltrindade commentedSame problem with IE8 / IE7, but this work for me.
Thanks man!!!!
Here is my new Helper Function:
[]´s
Comment #4
setvik commentedAttached is a patch of the above slightly reworked to only look at elements of pairs[i] that are of type 'string'.
Comment #5
manderson725 commentedI'm a little too green with drupal. I'm having this same issue I believe. Could someone give me a clue how to apply this patch? I get that it goes in the views/base.js file, but which line, etc. Thank you :)
Nevermind, i see where to do it..and i'll have to figure out how to get into core files to do so.
Comment #6
manderson725 commentedAs it turns out the error I get which is just like this one is because i'm using twitter widget code in a module. it is conflicting with drupal views javascript. Does anyone know if this patch will correct that conflict? Is anyone above also experiencing this along with a twitter widget?
Comment #7
vadim.eremeev commentedThanks for patch, guys!
@manderson725: yes, you right this bug maybe appear after I`ve installed twitter widget code, but thats quite interesting which conflicts can be there, gonna make analysis today
Comment #8
yang_yi_cn commented#4 works for me
Comment #9
bibo commentedIt seems there is a very similar issue with admin-module (admin.toolbar.js and twitter's widget.js = fatal error in Chrome, Safari and IE, but not Firefox or Safari).
It has been driving me nuts for a while.. but I guess this patch can be implemented for admin too.
I created an issue for that here: #797492: Toolbar won't open in Safari or Chrome. JS error in admin.toolbar.js
Comment #10
bibo commentedTo fix the same error in admin-module, I just added:
Comment #11
Johnny vd Laar commentedpatch seems to fix a bug on my project as well
Comment #12
t0b1 commentedthanks :)
Comment #13
pharoz commentedJust confirming that applying the patch also resolved my problem in IE8. Under chrome and firefox, there was no issue.
In IE, I had 2 areas that had AJAX pagination on and when I clicked on the next item in either area, it would refresh the entire page including the other AJAX pagination area. After the patch, each area paginated correctly independent of the other section.
Comment #14
Gekiboy commentedsetvik's patch is completely identical to a patch I made to resolve this issue. Since I came up with it independently, I think it's perfect :)
The issue is that for some reason the basic array object produced from calling the split function on a string has a function associated with it in some versions of IE. I'm not sure if this is a result of IE doing something weird or of another js library modifying the structure of the basic array object. Either way, the solution of checking each element to make sure it's a string before parsing it is effective and safe. It's a good solution until someone can get to the bottom of where the indexOf function is coming from.
Comment #15
dooug commentedI also independently created a similar patch. +1 for reviewed & tested. Hope to see this committed soon.
Comment #16
bleen commentedI have just tested the patch in #4 and it applied fine, and solved the problem I was having (described here: http://drupalbin.com/15283?nocache=1) with a function ending up as a "pair" causing a fatal error in webkit-based browsers.
RTBC++
Comment #17
bibo commentedHoping for a soonish commit too, since I hate patching important modules like views.
Even if the twitter-widget js is to blame for this incompatibilty, the problem is very avoidable. This small patch at #4 avoids JS conflicts without adding unnecessary complexity.
Comment #18
merlinofchaos commentedOk, guess we can consider this one fixed.
Comment #19
merlinofchaos commentedEr. COmmitted to all branches.
Comment #20
ianivs commentedThis fix works but I don't think it's the correct way to fix this.
The problem is the use of the for...in loop syntax, which loops over all properties of an object (except built-ins) and shouldn't really be used to iterate over arrays. For example, IE doesn't implement Array.indexOf so some javascript libraries may add an implementation to the Array prototype, which means that indexOf is now a user-defined property and will show up when using a for...in loop.
The proper fix is never to use this syntax to iterate over arrays, instead of
for (var in pairs)
you should use
for (var i=0; i < pairs.length; i++)
and you'll only iterate over the strings created by split.
Comment #21
dawehnerWhy not even use:
Comment #22
ianivs commentedThat's not the point :)
No need to bring jQuery into this when a for loop is perfectly fine. I'm just advocating the correct for loop synatx.
Comment #24
ChrisRut commentedI second the vote from ianivs #20, IE doesn't like this very much: http://drupal.org/files/issues/js-error_views.png
Proposed: http://drupal.org/files/issues/798764-views-base.js_.patch
Thanks also to stuartEngelhardt
Comment #25
ChrisRut commentedCorrected patch (forgot the 'i'): http://drupal.org/files/issues/798764-2-views-base.js_.patch
Comment #26
jm.federico commentedFrom #25
re-rolling against 6.x-2.11
Comment #27
jm.federico commentedChanging status
Comment #28
acondiff commentedthis is not working for me. =(
I did this and it says that there is an invalid argument in jquery.
Any ideas?
Comment #29
Web Assistant commentedI'm also getting the Invalid argument error in jquery.min.js (I'm using the jquery_update module if that makes any difference).
Just to update, this error wasn't related to the original problem, the patch worked for the initial error but my new problem was with using jquery ui.
Comment #30
jm.federico commented@acondiff, @rolandcarney
Can you provide more info about the error you are getting? Patch works for me and more ppl, there must be another module doing funny things with your js. Is it happening in eery browser?
@rolandcarney
Please open a new issue with your problem is it is caused by a different module. Specially if the patch was working before, or provide more details on how it relates to this case.
Comment #31
acondiff commentedIt is only in Internet Explorer. I also found it only throws the base.js error when the Shadowbox module is on. There must be some module causing your error because there is not an error in IE without this module on. There is probably a script or function that is causing this that is in several different modules.
After running the IE development tool it gave me the error that jQuery was undefined and it was caused by this line:
It is a line contained in a script tag that seems to be printed into my html page. It contains all of my views that use ajax ("home_posts" -uses ajax pager, and "home_district_standings" - uses ajax sorting). Any ideas?
Comment #32
jm.federico commented@acondiff
Which patch did you apply? What version of views are you using?
Hard to tell what prob is. I suggest you open a new issue with support request, otherwise it might end up highjacking this issue, which seems resolved.
Cheers
Comment #33
acondiff commentedMy new issue is created here: http://drupal.org/node/951494
Thanks.
Comment #34
jm.federico commentedBefore reporting an error please make sure you apply patch from #798764-26: base.js line 67 chrome, variable pairs[i] sometimes contain functions and not only stings, the one in #4 breaks in IE.
Cheers
Comment #35
merlinofchaos commentedThis patch is a dup of #514128: Use of 'for (i in my_array)' javascript array iteration causes issues when used with Prototype -- however, that patch broke things when it was committed and was reverted.
Comment #36
kingandySorry to revive old issues, but I don't believe this issue is a duplicate.
#514128 deals with use of the
for(var x in y)structure. This issue is in the following line, which is trying to performsplit()on a non-string. Nothing to do with the for loop.Unless the "pairs" variable has been strongly ensured to only contain strings, this issue still exists in 6.x-2.12 and 6.x-3.0-alpha3.
Looks like it's been fixed in 7.x-3.0-beta3, with the
if (typeof(pairs[i]) == 'string') {fix as presented in the patch in #4 (noelse {eval(pairs[i])}clause). Therefore I'm guessing all this needs is to be rolled against the current version and committed.Setting "to be ported" as the patch exists, and the code is in use in the D7 branch, but it doesn't look as though it'll work as is on the current release.
Comment #37
aaronbaumanThis has been fixed in 2.x-dev and 3.x-dev using the typeof operator
Comment #38
kingandyAh, sweet, I didn't think to check dev. Thanks!
Comment #40
omar alahmed#25 worked perfectly for me, thanks ChrisRut
Comment #41
ludo.rHas this patch been commited?
I still have this issue in 6.x-2.12
Here's the function :
EDIT : sorry, I just realized my version was prior to this patch.