-
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
- Loading branch information
Showing
2 changed files
with
50 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,45 @@ | ||
<?php | ||
|
||
/** | ||
* @group script-dependencies | ||
*/ | ||
class Test_Script_Dependencies extends WP_UnitTestCase { | ||
/** | ||
* 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 ) { | ||
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', | ||
'wp-upload-media', | ||
); | ||
|
||
sort( $expected, SORT_STRING ); | ||
sort( $dependents, SORT_STRING ); | ||
|
||
$this->assertSame( $expected, $dependents ); | ||
} | ||
} |