Make WordPress Core

Opened 5 months ago

Closed 4 months ago

Last modified 2 months ago

#60348 closed defect (bug) (fixed)

Script Modules API: Add import map polyfill for older browsers.

Reported by: cbravobernal's profile cbravobernal Owned by: gziolo's profile gziolo
Milestone: 6.5 Priority: normal
Severity: normal Version:
Component: Script Loader Keywords: has-patch has-unit-tests commit add-to-field-guide
Focuses: Cc:

Description (last modified by cbravobernal)

Add a polyfill to make import maps compatibles with Safari versions under 15.

Syncs the changes from https://github.com/WordPress/gutenberg/pull/58263 to core.
Adds a polyfill to make import maps compatible with Safari old versions (under 15).

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

Attached screenshots.
https://github.com/WordPress/wordpress-develop/assets/37012961/03cb3163-c9e3-458e-a216-463ab98f5039
https://github.com/WordPress/wordpress-develop/assets/37012961/ba09e4f3-d349-4bfc-b7a3-924746abd909

Change History (19)

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


5 months ago
#1

  • Keywords has-patch added

#2 @jorbin
5 months ago

This looks to be related to a feature added in 6.5. We generally only backport fixes for bugs introduced during that release. Why do you think it should be backported?

#3 @cbravobernal
5 months ago

  • Summary changed from Backport: Add import map polyfill for modules. to Add import map polyfill for modules.

With backport I meant moving code that has been in Gutenberg to Core, in 6.5.

At least we call them backports in the sync issue:
https://github.com/WordPress/gutenberg/issues/57959

If it has a different meaning in Core, I will change the title.

Modules will be available in 6.5, and would be cool to have them also working in old Safari versions.

Thanks for the info!

#4 @jorbin
5 months ago

  • Component changed from General to Script Loader
  • Milestone changed from Awaiting Review to 6.5

Thanks for the clarification. A backport means moving from one branch to another in core.

Adjusting the milestone and component.

#5 @cbravobernal
5 months ago

  • Description modified (diff)

#8 @cbravobernal
5 months ago

  • Summary changed from Add import map polyfill for modules. to Script Modules API: Add import map polyfill for older browsers.

@gziolo commented on PR #5947:


5 months ago
#9

Code-wise it seems to be ready to go. Do we have unit tests covering other polyfills? We could verify if the script prints when there are items in the import map.

#10 @luisherranz
5 months ago

#60232 was marked as a duplicate.

@cbravobernal commented on PR #5947:


5 months ago
#11

Code-wise it seems to be ready to go. Do we have unit tests covering other polyfills? We could verify if the script prints when there are items in the import map.

I will take a look at it, if not, I will check if can add unit tests to cover them.

#12 @gziolo
4 months ago

  • Keywords has-unit-tests commit added

#13 @gziolo
4 months ago

  • Owner set to gziolo
  • Resolution set to fixed
  • Status changed from new to closed

In 57492:

Script Modules API: Add import map polyfill for older browsers

Syncs the changes from https://github.com/WordPress/gutenberg/pull/58263. Adds a polyfill to make import maps compatible with unsported browsers (https://caniuse.com/import-maps).

Fixes #60348.
Props cbravobernal, jorbin, luisherranz, jonsurrell.

#15 @stevenlinx
4 months ago

  • Keywords add-to-field-guide added

#16 @swissspidy
2 months ago

@gziolo Was this specifically added for Safari < 15? Do we even support that?

#17 @gziolo
2 months ago

Was this specifically added for Safari < 15? Do we even support that?

As far as I remember it could be tested in Safari 14 but the same issue existed for other browsers as listed in https://caniuse.com/mdn-html_elements_script_type_importmap. The browser support is at 90% overall, but I'm not entirely sure how to compare that with what WordPress officially supports.

#18 @swissspidy
2 months ago

The browserslist website makes it easy to compare that. I just opened #60970 because of that.

#19 @gziolo
2 months ago

That would be the query with the browsers WP supports:
https://browsersl.ist/#q=%3E1%25%2C+last+1+Android+versions%2C+last+1+ChromeAndroid+versions%2C+last+2+Chrome+versions%2C+last+2+Firefox+versions%2C+last+2+Safari+versions%2C+last+2+iOS+versions%2C+last+2+Edge+versions%2C+last+2+Opera+versions

It looks like we don't need the polyfill for the import map, taking into account the list of currently supported browsers.

Note: See TracTickets for help on using tickets.