chrisblakley / Nebula

Nebula is a WordPress theme framework that focuses on enhancing development. The core features of Nebula make it a powerful tool for designing, developing, and analyzing WordPress websites consistently, yet its deliberately uncomplicated code syntax also serves as a learning resource for programmers themselves.
https://nebula.gearside.com
GNU General Public License v3.0
144 stars 36 forks source link

Updating localstorage data for Contact Form 7 crashes IE 11 #1711

Closed terencehoverter closed 6 years ago

terencehoverter commented 6 years ago

Commenting out this line seems to fix the issue for Contact Form 7 v5.0.2: https://github.com/chrisblakley/Nebula/blob/master/assets/js/nebula.js#L1981

chrisblakley commented 6 years ago

This is interesting, but we're seeing this happen on Windows 10 on IE 11.165.17134.0.

terencehoverter commented 6 years ago

okay, I don't think it has to do with Line 1981, rather Lines 1986-1993

For the lazy:

nebula.dom.window.on('storage', function(e){
    jQuery('.wpcf7-textarea, .wpcf7-text').each(function(){
        if ( !jQuery(this).hasClass('do-not-store') && !jQuery(this).hasClass('.wpcf7-captchar') ){
            jQuery(this).val(localStorage.getItem('cf7_' + jQuery(this).attr('name'))).trigger('keyup');
        }
    });
});

More specifically this line here:

jQuery(this).val(localStorage.getItem('cf7_' + jQuery(this).attr('name'))).trigger('keyup');
terencehoverter commented 6 years ago

Contextual Notes:

chrisblakley commented 6 years ago

I can recreate this now in IE11. I can see the infinite loop on the storage event. For reference, I have the same version at home (IE 11.165.17134.0 on Windows 10).

chrisblakley commented 6 years ago

I'm not in love with this solution, but this isn't a flagship feature. This simply disables localstorage on IE11:

var isIE11 = !!window.MSInputMethodContext && !!document.documentMode; //Check for IE11
if ( !jQuery('.wpcf7-form').length || isIE11 || jQuery('.ie').length ){
    return false;
}