WordPress / wp-jquery-update-test

WordPress plugin to test updates for jQuery and jQuery UI
16 stars 8 forks source link

No warnings..... using the plugin #11

Open BackuPs opened 3 years ago

BackuPs commented 3 years ago

Hi

When using the plugin on wp 5.5.3 and turning on jquery 3.5.1 and or turn ON or OFF jquery migrate i see no warning messages. Even if i turn on debug_script in the wp-config.php.

Loading wp 5.7 which by default ships with the latest jquery migrate i see warning messages like these

afbeelding

But even if i unload jquery migrate everything works just fine.

In wp 5.5.3 and turning off jquery migrate in the test jquery plugin every thing works just fine with jquery 3.5.1

According to the warning i must rewrite image.hover(function to image.on('hover', function(....

But if i rewrite this

    var enable_image_hover = function(image) {
        if (image.is(".image_icon_zoom,.image_icon_play,.image_icon_doc,.image_icon_link")) {
            image.hover(function() {
                $(".image_overlay", this).animate({
                    opacity: '1'
                }, "fast");
            }, function() {
                $(".image_overlay", this).animate({
                    opacity: '0'
                }, "fast");
            });
            if (image.find('.image_overlay').length == 0) {
                image.children('img').after($('<span class="image_overlay"></span>').css({
                    opacity: '0',
                    visibility: 'visible'
                }));
            }
         }
    };

to this and replace on line 3 .hover for on("hover"... it stops working whereas the old function in wp 5.7 or 5.5.3 without jquery migrate just works fine.

var enable_image_hover = function(image) {
    if (image.is(".image_icon_zoom,.image_icon_play,.image_icon_doc,.image_icon_link")) {
        image.on('mouseenter', '.image_overlay', function() {
            $(this).animate({
                opacity: '1'
            }, "fast");
        });
        image.on('mouseleave', '.image_overlay', function() {
            $(this).animate({
                opacity: '0'
            }, "fast");
        });         
        if (image.find('.image_overlay').length == 0) {
            image.children('img').after($('<span class="image_overlay"></span>').css({
                opacity: '0',
                visibility: 'visible'
            }));
        }
     }
};

The question i have is

1) why even without the jquery migrate loaded are these scripts still working just fine with jquery 3.5.1

2) and why is wp 5.5.3 with the test jquery updates plugin not showing any warnings at all even with jquery migrate turned on. These messages only appear in wp 5.7 beta when scripts_debug is set to true