Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#59778 closed defect (bug) (maybelater)

remove not needed function call in wp_post_preview_js

Reported by: pbearne's profile pbearne Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Script Loader Keywords: has-patch close
Focuses: javascript Cc:

Description (last modified by pbearne)

In this function, we created some JS with "<script>" tags and removed them with a call to wp_remove_surrounding_empty_script_tags()

So this patch removes the tags and function call

see ticket #59775 for tests for this function/change

Change History (6)

#1 @pbearne
2 years ago

  • Description modified (diff)

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


2 years ago
#2

  • Keywords has-patch added

#3 @mukesh27
2 years ago

  • Component changed from Editor to Script Loader
  • Focuses javascript added

Thanks @pbearne for the ticket and PR!

@westonruter added the wp_remove_surrounding_empty_script_tags function in [56748] / #58664. I'd appreciate getting his thoughts on this matter.

#4 @pbearne
2 years ago

I agree the change made by @westonruter was an improvement of what was there before, and having the <script> tag makes clear that you are looking at a block JS code.

But in all the cases, you could not include the <script> tag and get the same output with one less call.

#5 @westonruter
2 years ago

  • Keywords close added

The <script> tag is needed for the sake of IDEs to do static analysis at development time. Since this JavaScript code is not run through any linters at build time, having every bit of development support at code time is important. The removal of wp_remove_surrounding_empty_script_tags() should only happen once the <script> wrappers aren't needed anymore, which would be done as part of #59444. Once the minimum version of PHP is bumped to 7.3, then HEREDOC strings can be used instead of the <script> wrappers and wp_remove_surrounding_empty_script_tags() can be removed.

#6 @pbearne
2 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from new to closed

@westonruter, thanks for the feedback
I agree on to closing this ticket and will try to remember to update when we bump the PHP version.

Note: See TracTickets for help on using tickets.