-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exclude Iterator helpers from polyfills (#69070)
* Exclude Iterator helpers from polyfills * Use assertEqualSets * Ignore bundled packages Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: swissspidy <swissspidy@git.wordpress.org>
- Loading branch information
1 parent
e850c68
commit c9ee64a
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
/** | ||
* @group script-dependencies | ||
*/ | ||
class Test_Script_Dependencies extends WP_UnitTestCase { | ||
public $bundled_scripts = array( 'wp-upload-media' ); | ||
|
||
/** | ||
* Tests for accidental `wp-polyfill` script dependents. | ||
*/ | ||
public function test_polyfill_dependents() { | ||
$scripts = wp_scripts(); | ||
$registered_scripts = $scripts->registered; | ||
$dependents = array(); | ||
|
||
// Iterate over all registered scripts, finding dependents of the `wp-polyfill` script. | ||
// Based on private `WP_Scripts::get_dependents` method. | ||
foreach ( $registered_scripts as $registered_handle => $args ) { | ||
// Ignore bundled packages, they don't load separate polyfills. | ||
if ( in_array( $registered_handle, $this->bundled_scripts, true ) ) { | ||
continue; | ||
} | ||
|
||
if ( in_array( 'wp-polyfill', $args->deps, true ) ) { | ||
$dependents[] = $registered_handle; | ||
} | ||
} | ||
|
||
// This list should get smaller over time as we remove `wp-polyfill` dependencies. | ||
// If the list update is intentional, please add a comment explaining why. | ||
$expected = array( | ||
'react', | ||
'wp-blob', | ||
'wp-block-editor', | ||
'wp-block-library', | ||
'wp-blocks', | ||
'wp-edit-site', | ||
'wp-core-data', | ||
'wp-editor', | ||
'wp-router', | ||
'wp-url', | ||
'wp-widgets', | ||
); | ||
|
||
$this->assertEqualSets( $expected, $dependents ); | ||
} | ||
} |