diff --git a/src/functions/common.php b/src/functions/common.php index 1fe3f17..b05517e 100644 --- a/src/functions/common.php +++ b/src/functions/common.php @@ -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 []; }