Make WordPress Core

Opened 3 months ago

Last modified 10 days ago

#64425 new defect (bug)

JQuery .proxy deprecated and QMIGRATE: Boolean attribute 'disabled' is not set to its lowercased name in Jquery 4.0

Reported by: neo2k23's profile neo2k23 Owned by:
Milestone: 7.0 Priority: normal
Severity: normal Version: trunk
Component: General Keywords: has-patch jquery-4 dev-feedback needs-refresh
Focuses: Cc:

Description

Hi

I am using the latest Test jQuery Updates plugin to test jquery 4.0 and i get the following jquery migrate warnings when trying to insert a image from the media library in a plugin setting.

		JQMIGRATE: jQuery.proxy() is deprecated jquery-migrate-4.0.0-beta.1.js:136:28
		console.trace() JQMIGRATE: jQuery.proxy() is deprecated jquery-migrate-4.0.0-beta.1.js:142:13
			jQuery 3
			Uploader http://server.tst/wp-includes/js/plupload/wp-plupload.js?ver=7.0-alpha-61387:74
			ready http://server.tst/wp-includes/js/media-views.js?ver=7.0-alpha-61387:9608

and this one.

		console.trace() JQMIGRATE: Boolean attribute 'disabled' is not set to its lowercased name jquery-migrate-4.0.0-beta.1.js:142:13
			jQuery 8
			render http://server.tst/wp-includes/js/media-views.js?ver=7.0-alpha-61387:1337
			Backbone 5
			refresh http://server.tst/wp-includes/js/media-views.js?ver=7.0-

Please fix. Thank you

Change History (12)

#1 @neo2k23
3 months ago

I found one fix

changing line 1337 and line 5794 in media-views.js from attr to prop fixes that warning message.

    this.$el.prop( 'disabled', model.disabled );

changing line 74 in wp-upload.js to

	this[ key ] = this[ key ].bind( this );

Fixes the .proxy warning but i am not sure that is the correct fix as because .bind does not set guid on the bound function instances so that proxied event handlers can be removed without storing the instance of the proxied function.

Version 1, edited 3 months ago by neo2k23 (previous) (next) (diff)

#2 @azaozz
3 months ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 7.0

Replacing attr with prop should be straightforward. Thinking many of these were fixed earlier but seems there are more places where this is needed.

Not completely sure about $.proxy too. Needs more testing.

This ticket was mentioned in PR #10661 on WordPress/wordpress-develop by @hbhalodia.


3 months ago
#3

  • Keywords has-patch added; needs-patch removed

Trac ticket: https://core.trac.wordpress.org/ticket/64425

  • Updated attr to use prop.
  • Use bind instead of proxy with a comment to update the function used with namespace.

#4 @hbhalodia
3 months ago

Hi @neo2k23 @azaozz, I have added the PR for the same. As said, we need to test the bind related changes, because we do not know in what context it the function can be instantiated.

Thanks,

#5 follow-up: @neo2k23
3 months ago

@hbhalodia @azaozz i scanned the current beta version wp 7 for all .proxy instances and there are in total 4 files using .proxy

https://share.zight.com/jkuNXqA8

medialeement-and-player.js
tinymce.min.js
wp-upload.js
wp-tinymce.js

It was already clear to me that just replacing .proxy with .bind could cause issues as .bind does not set guid on the bound function instances so that proxied event handlers can be removed without storing the instance of the proxied function.

Thanks all and have a great XMas.

#6 in reply to: ↑ 5 @azaozz
2 months ago

Replying to neo2k23:

medialeement-and-player.js
tinymce.min.js
wp-upload.js
wp-tinymce.js

Most of these are (older) external libraries, not sure if they can be/should be patched by WP. At the same time it seems there aren't plans upstream to remove support for $.proxy for now, so can probably leave it as-is. Can fix wp-upload.js though.

Thanks all and have a great XMas.

Thanks, you too!

Last edited 2 months ago by azaozz (previous) (diff)

This ticket was mentioned in Slack in #core by audrasjb. View the logs.


11 days ago

#8 @joedolson
11 days ago

  • Keywords jquery-4 added

#9 follow-up: @audrasjb
11 days ago

As per today's bug scrub: The patch doesn't looks too much complex so I'm inclined to keep it in 7.0, but we'll need an owner for this. @azaozz are you ok with the current proposal?

#10 @audrasjb
11 days ago

  • Keywords dev-feedback added

#11 in reply to: ↑ 9 @azaozz
11 days ago

  • Keywords needs-refresh added

Replying to audrasjb:

Looking at the PR, replacing attr with prop is okay imho.

Not 100% sure about $.proxy and bind. Seems to work as far as I've tested but it also binds everything in this. Perhaps the changed unbinding may get triggered in some case (plugins hooking up there?). As it seems there are no plans upstream to discontinue support for $.proxy thinking we can keep it for now, moreover it is also used in couple external libraries.

#12 @hbhalodia
10 days ago

Hi @audrasjb @azaozz, For now as discussed above, since there are no plans on upstream to discontinue support for $.proxy, I have reverted the change related to that in the PR. Though I have kept the change related to attr and prop.

Let me know if there is anything more on the PR to add.

Thanks,

Note: See TracTickets for help on using tickets.