Unverified Commit a2c58dda authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3197553 by beatrizrodrigues, longwave, daffie: Deprecate drupal_js_defaults()

parent 09795b6e
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -201,9 +201,13 @@ function base_path() {
 * @param $data
 *   (optional) The default data parameter for the JavaScript asset array.
 *
 * @see hook_js_alter()
 * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. No direct
 *   replacement is provided.
 *
 * @see https://www.drupal.org/node/3197679
 */
function drupal_js_defaults($data = NULL) {
  @trigger_error('drupal_js_defaults() is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. No direct replacement is provided. See https://www.drupal.org/node/3197679', E_USER_DEPRECATED);
  return [
    'type' => 'file',
    'group' => JS_DEFAULT,
+1 −2
Original line number Diff line number Diff line
@@ -60,8 +60,7 @@ public function getCssAssets(AttachedAssetsInterface $assets, $optimize);
   * Note that hook_js_alter(&$javascript) is called during this function call
   * to allow alterations of the JavaScript during its presentation. The correct
   * way to add JavaScript during hook_js_alter() is to add another element to
   * the $javascript array, deriving from drupal_js_defaults(). See
   * locale_js_alter() for an example of this.
   * the $javascript array. See locale_js_alter() for an example of this.
   *
   * @param \Drupal\Core\Asset\AttachedAssetsInterface $assets
   *   The assets attached to the current response.
+0 −1
Original line number Diff line number Diff line
@@ -853,7 +853,6 @@ function hook_element_plugin_alter(array &$definitions) {
 * @param \Drupal\Core\Asset\AttachedAssetsInterface $assets
 *   The assets attached to the current response.
 *
 * @see drupal_js_defaults()
 * @see \Drupal\Core\Asset\AssetResolver
 */
function hook_js_alter(&$javascript, \Drupal\Core\Asset\AttachedAssetsInterface $assets) {
+10 −0
Original line number Diff line number Diff line
@@ -487,4 +487,14 @@ public function testAddJsFileWithQueryString() {
    $this->assertStringContainsString('<script src="' . str_replace('&', '&amp;', $this->fileUrlGenerator->generateString('core/modules/system/tests/modules/common_test/querystring.js?arg1=value1&arg2=value2')) . '&amp;' . $query_string . '"></script>', $rendered_js, 'JavaScript file with query string gets version query string correctly appended.');
  }

  /**
   * Tests deprecated drupal_js_defaults() function.
   *
   * @group legacy
   */
  public function testDeprecatedDrupalJsDefaults() {
    $this->expectDeprecation('drupal_js_defaults() is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. No direct replacement is provided. See https://www.drupal.org/node/3197679');
    $this->assertIsArray(drupal_js_defaults());
  }

}