Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid procedure call or argument error in IE9 > IE8 Mode #137

Closed
olemarius opened this issue Sep 27, 2012 · 11 comments
Closed

Invalid procedure call or argument error in IE9 > IE8 Mode #137

olemarius opened this issue Sep 27, 2012 · 11 comments

Comments

@olemarius
Copy link

I get an error with yepnope - 1.5.4pre when refreshing the page in IE8 (turned off caching to reproduce every time). I'll try to provide as much relevant info as possible, let me know if you need anything else:

My code:

    yepnope({
    load: '/scripts/libs/jquery/jquery.validate-1.9.0/jquery.validate.min.js',
    complete: function () { 
            console.log('damn you ie8!');
    }
    });

The error:

SCRIPT5: Invalid procedure call or argument
BuiltJS.rails, line 1022 character 15
SCRIPT5: Invalid procedure call or argument
BuiltJS.rails, line 1022 character 15

    if ( first ) {
      if ( elem != "img" ) {
        sTimeout(function(){ insBeforeObj.removeChild( preloadElem ) }, 50);
      }

      for ( var i in scriptCache[ url ] ) {
        if ( scriptCache[ url ].hasOwnProperty( i ) ) {
          scriptCache[ url ][ i ].onload(); // Error on this line
        }
      }
    }

Here's what I get when hovering the scriptCache:

[-] scriptCache {...} Object
[+] [prototype] {...} Object
[+] /scripts/core/forms.min.js [] Object, (Array)
[+] /scripts/libs/jquery/jquery.validate-1.9.0/jquery.validate.min.js [[object HTMLScriptElement]] Object, (Array)
[+] /scripts/libs/jquery/ui.Wizard.js [] Object, (Array)
/Scripts/polyfills/jquery-placeholder/jquery.placeholder.min.js 2 Number

Will continue debugging this and let you know if I figure out anything..

@SlexAxton
Copy link
Owner

We've seen some issues when other script elements are removed from the page. Could that be happening?

Thanks for the info/report!

@olemarius
Copy link
Author

Just realized this part of the project is a huge mess. I'll clean it up and try to nail exactly what's causing this along the way, or if the issue is still there after the cleanup. I should be able to make a sandbox test for it if it's still an issue.

@olemarius
Copy link
Author

Is it possible that some systems might have "always refresh from server" as default setting in their IE8, and this forces yepnope to actually load scripts twice? Some of our clients are on terminals with pretty high security settings, so I'm worried this might be the reason I get a lot of weird errors.

I get errors when 1) Hitting Ctrl + F5 like a maniac (30+ times) and 2) when turning on "Always refresh from cache". And now specifically when loading scripts that uses $.widget in jQuery which I think can break if jQuery (or other scripts) is loaded twice.

@SlexAxton
Copy link
Owner

Sorry for the brevity but I'm mobile:

The setting would definitely cause dual downloads but it wouldn't cause
dual executions.

Are you noticing things run twice?

@olemarius
Copy link
Author

We've seen some issues when other script elements are removed from the page. Could that be happening?

By this you mean adding or removing script tags to the DOM? No I dont think that's happening. Can it be because I have multiple instances of Modernizr.load ? I have widget A, B and C, and each installation of this has a Modernizr.load({ ... }); which some times loads the same scripts. I suspect I might be using it wrong :)

@olemarius
Copy link
Author

Just saw this issue: #96 (comment)

It actually might be what's happening in my case as well.

@YoussefTaghlabi
Copy link
Contributor

I see where the issue is...
preloadElem onload is defined as the following:

    // Attach handlers for all browsers
    preloadElem.onerror = preloadElem.onload = preloadElem.onreadystatechange = function(){
      onload.call(this, firstFlag);
    };

It gets nulled once onload fires:

    function onload ( first ) {
        .........

        // Handle memory leak in IE
        preloadElem.onload = preloadElem.onreadystatechange = null;

Inside the onload function we run through the scripcache array as:

          for ( var i in scriptCache[ url ] ) {
            if ( scriptCache[ url ].hasOwnProperty( i )) {  
                scriptCache[ url ][ i ].onload();
            }
          }

In IE, it sees that onload has been nulled, hence scriptCache[ url ][ i ].onload() will raise an exception.
I get this behavior on all IE versions.

@SlexAxton
Copy link
Owner

Hi @YoussefTaghlabi (and all). I'm just getting back from overseas, but that's a good find. Would you consider submitting a pull-request to fix it. /cc @ralphholzmann

@YoussefTaghlabi
Copy link
Contributor

Sure, I'll submit a pull-request by tomorrow.

@YoussefTaghlabi
Copy link
Contributor

Done.

@SlexAxton
Copy link
Owner

Fixed in #139

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants