Make WordPress Core


Ignore:
Timestamp:
08/29/2024 06:04:02 AM (7 months ago)
Author:
swissspidy
Message:

Script Loader: Remove importmap polyfill.

The polyfill was added in [57492], but all browsers supported by WordPress already support import maps.

This not only disables the polyfill, but completely removes it as it was only added recently and there is no usage outside of core.

Props swissspidy, desrosj, luisherranz, gziolo.
Fixes #60970.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/script-modules/wpScriptModules.php

    r58579 r58952  
    699699        $this->assertCount( 1, $import_map );
    700700        $this->assertStringStartsWith( '/dep.js', $import_map['dep'] );
    701     }
    702 
    703     /**
    704      * @ticket 60348
    705      *
    706      * @covers ::print_import_map_polyfill()
    707      */
    708     public function test_wp_print_import_map_has_no_polyfill_when_no_modules_registered() {
    709         $import_map_polyfill = get_echo( array( $this->script_modules, 'print_import_map' ) );
    710 
    711         $this->assertSame( '', $import_map_polyfill );
    712     }
    713 
    714     /**
    715      * @ticket 60348
    716      *
    717      * @covers ::print_import_map_polyfill()
    718      */
    719     public function test_wp_print_import_map_has_polyfill_when_modules_registered() {
    720         $script_name = 'wp-polyfill-importmap';
    721         wp_register_script( $script_name, '/wp-polyfill-importmap.js' );
    722 
    723         $this->script_modules->enqueue( 'foo', '/foo.js', array( 'dep' ), '1.0' );
    724         $this->script_modules->register( 'dep', '/dep.js' );
    725         $import_map_polyfill = get_echo( array( $this->script_modules, 'print_import_map' ) );
    726 
    727         wp_deregister_script( $script_name );
    728 
    729         $p = new WP_HTML_Tag_Processor( $import_map_polyfill );
    730         $p->next_tag( array( 'tag' => 'SCRIPT' ) );
    731         $id = $p->get_attribute( 'id' );
    732 
    733         $this->assertSame( 'wp-load-polyfill-importmap', $id );
    734701    }
    735702
Note: See TracChangeset for help on using the changeset viewer.