Skip to content

Commit

Permalink
Fix drupal_add_js()
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenoh committed Nov 16, 2023
1 parent 056369d commit b1447e5
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/functions/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,16 +236,18 @@ function drupal_add_js(array|string|null $data = null, array|string|null $option

case 'inline':
$attachment_subscriber->addAttachments([
'js' => [$options],
'js' => $options,
]);
break;

default:
$attachment_subscriber->addAttachments([
'js' => [
$options['data'] => $options,
],
]);
if (is_string($data)) {
$attachment_subscriber->addAttachments([
'js' => [
$data => $options,
],
]);
}
}
return [];
}
Expand Down

0 comments on commit b1447e5

Please sign in to comment.