Skip to content

Commit

Permalink
Remove uniqueness checks
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed Dec 17, 2024
1 parent a7ea9a9 commit 31ec071
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/wp-includes/class-wp-script-modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,11 @@ class WP_Script_Modules {
* Holds script module identifiers that have been marked for inclusion in the import map.
*
* A script module that appears here should be include in the import map regardless of
* whether it is a dependency of another script module.
*
* The values in this array are always `null`. The presence of a Module IDs
* as an array key marks the script module for inclusion in the import map.
* Different values are reserved for possible future use.
* whether it is in the dependency graph of enqueued script modules.
*
* @since 6.8.0
*
* @var array<string, null>
* @var string[]
*/
private $marked_for_inclusion = array();

Expand Down Expand Up @@ -176,7 +172,7 @@ public function enqueue( string $id, string $src = '', array $deps = array(), $v
* @param string $id The identifier of the script module.
*/
public function include_in_import_map( string $id ) {
$this->marked_for_inclusion[ $id ] = null;
$this->marked_for_inclusion[] = $id;
}

/**
Expand Down Expand Up @@ -309,7 +305,7 @@ public function print_import_map() {
*/
private function get_import_map(): array {
$imports = array();
$script_module_ids = array_unique( array_keys( $this->marked_for_inclusion ) + array_keys( $this->get_marked_for_enqueue() ) );
$script_module_ids = $this->marked_for_inclusion + array_keys( $this->get_marked_for_enqueue() );

foreach ( $this->get_dependencies( $script_module_ids ) as $id => $script_module ) {
$src = $this->get_src( $id );
Expand All @@ -318,7 +314,7 @@ private function get_import_map(): array {
}
$imports[ $id ] = $src;
}
foreach ( $this->marked_for_inclusion as $id => $_ ) {
foreach ( $this->marked_for_inclusion as $id ) {
$src = $this->get_src( $id );
if ( null === $src ) {
continue;
Expand Down

0 comments on commit 31ec071

Please sign in to comment.