Changeset 61073
- Timestamp:
- 10/27/2025 04:10:24 PM (7 weeks ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
src/wp-includes/class-wp-script-modules.php (modified) (5 diffs)
-
tests/phpunit/tests/script-modules/wpScriptModules.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-script-modules.php
r60999 r61073 399 399 ) { 400 400 // If any dependency is set to be printed in footer, skip printing this module in head. 401 $dependencies = $this->get_dependencies( array( $id) );401 $dependencies = array_keys( $this->get_dependencies( array( $id ) ) ); 402 402 foreach ( $dependencies as $dependency_id ) { 403 403 if ( … … 529 529 private function get_import_map(): array { 530 530 $imports = array(); 531 foreach ( $this->get_dependencies( $this->queue) as $id ) {531 foreach ( array_keys( $this->get_dependencies( $this->queue ) ) as $id ) { 532 532 $src = $this->get_src( $id ); 533 533 if ( '' !== $src ) { … … 567 567 * @param string[] $import_types Optional. Import types of dependencies to retrieve: 'static', 'dynamic', or both. 568 568 * Default is both. 569 * @return string[] List of IDs for script module dependencies.569 * @return array<string, array> List of dependencies, keyed by script module identifier. 570 570 */ 571 571 private function get_dependencies( array $ids, array $import_types = array( 'static', 'dynamic' ) ): array { … … 585 585 isset( $this->registered[ $dependency['id'] ] ) 586 586 ) { 587 $all_dependencies[ $dependency['id'] ] = true;587 $all_dependencies[ $dependency['id'] ] = $this->registered[ $dependency['id'] ]; 588 588 589 589 // Add this dependency to the list to get dependencies for. … … 593 593 } 594 594 595 return array_keys( $all_dependencies );595 return $all_dependencies; 596 596 } 597 597 -
trunk/tests/phpunit/tests/script-modules/wpScriptModules.php
r61041 r61073 226 226 $reflection_class = new ReflectionClass( wp_script_modules() ); 227 227 $get_marked_for_enqueue = $reflection_class->getMethod( 'get_marked_for_enqueue' ); 228 $get_dependencies = $reflection_class->getMethod( 'get_dependencies' ); 228 229 if ( PHP_VERSION_ID < 80100 ) { 229 230 $get_marked_for_enqueue->setAccessible( true ); 231 $get_dependencies->setAccessible( true ); 230 232 } 231 233 … … 255 257 $this->assertIsArray( $marked_for_enqueue['a'], 'Expected script module "a" to have an array entry.' ); 256 258 $this->assertSame( '/a.js', $marked_for_enqueue['a']['src'], 'Expected script module "a" to have the given src.' ); 259 $this->assertSame( array(), $get_dependencies->invoke( wp_script_modules(), array( 'a' ) ) ); 257 260 258 261 // One Dependency. … … 261 264 $this->assertTrue( wp_script_modules()->set_fetchpriority( 'b', 'low' ) ); 262 265 $this->assertSame( array( 'a', 'b' ), wp_script_modules()->get_queue() ); 266 $this->assertSame( 267 array( 268 'b-dep' => array( 269 'src' => '/b-dep.js', 270 'version' => false, 271 'dependencies' => array(), 272 'in_footer' => false, 273 'fetchpriority' => 'auto', 274 ), 275 ), 276 $get_dependencies->invoke( wp_script_modules(), array( 'b' ) ) 277 ); 263 278 264 279 // Two dependencies with different formats and a false version.
Note: See TracChangeset
for help on using the changeset viewer.