Changeset 43788
- Timestamp:
- 10/22/2018 06:12:55 AM (6 years ago)
- Location:
- branches/5.0
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.0
-
branches/5.0/src/wp-includes/class.wp-scripts.php
r41686 r43788 265 265 if ( $after_handle ) { 266 266 $after_handle = sprintf( "<script type='text/javascript'>\n%s\n</script>\n", $after_handle ); 267 } 268 269 if ( $before_handle || $after_handle ) { 270 $inline_script_tag = "{$cond_before}{$before_handle}{$after_handle}{$cond_after}"; 271 } else { 272 $inline_script_tag = ''; 267 273 } 268 274 … … 308 314 309 315 // A single item may alias a set of items, by having dependencies, but no source. 310 if ( ! $obj->src ) { 316 if ( ! $src ) { 317 if ( $inline_script_tag ) { 318 if ( $this->do_concat ) { 319 $this->print_html .= $inline_script_tag; 320 } else { 321 echo $inline_script_tag; 322 } 323 } 324 311 325 return true; 312 326 } -
branches/5.0/tests/phpunit/tests/dependencies/scripts.php
r43738 r43788 396 396 $expected = "<script type='text/javascript'>\nconsole.log(\"before\");\n</script>\n"; 397 397 $expected .= "<script type='text/javascript' src='http://example.com'></script>\n"; 398 $expected .= "<script type='text/javascript'>\nconsole.log(\"after\");\n</script>\n"; 399 400 $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); 401 } 402 403 /** 404 * @ticket 44551 405 */ 406 function test_wp_add_inline_script_before_for_handle_without_source() { 407 wp_register_script( 'test-example', '' ); 408 wp_enqueue_script( 'test-example' ); 409 wp_add_inline_script( 'test-example', 'console.log("before");', 'before' ); 410 411 $expected = "<script type='text/javascript'>\nconsole.log(\"before\");\n</script>\n"; 412 413 $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); 414 } 415 416 /** 417 * @ticket 44551 418 */ 419 function test_wp_add_inline_script_after_for_handle_without_source() { 420 wp_register_script( 'test-example', '' ); 421 wp_enqueue_script( 'test-example' ); 422 wp_add_inline_script( 'test-example', 'console.log("after");' ); 423 424 $expected = "<script type='text/javascript'>\nconsole.log(\"after\");\n</script>\n"; 425 426 $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); 427 } 428 429 /** 430 * @ticket 44551 431 */ 432 function test_wp_add_inline_script_before_and_after_for_handle_without_source() { 433 wp_register_script( 'test-example', '' ); 434 wp_enqueue_script( 'test-example' ); 435 wp_add_inline_script( 'test-example', 'console.log("before");', 'before' ); 436 wp_add_inline_script( 'test-example', 'console.log("after");' ); 437 438 $expected = "<script type='text/javascript'>\nconsole.log(\"before\");\n</script>\n"; 398 439 $expected .= "<script type='text/javascript'>\nconsole.log(\"after\");\n</script>\n"; 399 440
Note: See TracChangeset
for help on using the changeset viewer.