Skip to content

Commit

Permalink
feat(scripts): Improve interoperatbility with other #pre_render hooks
Browse files Browse the repository at this point in the history
Selectively replace the default #pre_render hook instead of setting the
exact list. This allows additional hooks to be set by other modules.
  • Loading branch information
torotil committed Nov 4, 2024
1 parent a5ed3b8 commit 0772a04
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion theming.module
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ function theming_theme_registry_alter(&$hooks) {
* Implements hook_element_info_alter().
*/
function theming_element_info_alter(&$info) {
$info['scripts']['#pre_render'] = ['theming_pre_render_scripts'];
// Replace the default #pre_render callback for scripts.
$info['scripts']['#pre_render'] = array_map(function ($hook) {
return $hook == 'drupal_pre_render_scripts' ? 'theming_pre_render_scripts' : $hook;
}, $info['scripts']['#pre_render']);
}

/**
Expand Down

0 comments on commit 0772a04

Please sign in to comment.