Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix javascript enqueue handle #239

Merged
merged 4 commits into from
Jul 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/Roots/Acorn/Assets/Bundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function css(?callable $callable = null)
*
* Optionally pass a function to execute on each JS file.
*
* @param callable $callable
* @param callable $callable
* @return Collection|$this
*/
public function js(?callable $callable = null)
Expand All @@ -88,7 +88,7 @@ public function js(?callable $callable = null)
}

/**
* Get depdencies.
* Get the bundle dependencies.
*
* @return array
*/
Expand All @@ -98,7 +98,7 @@ public function dependencies()
}

/**
* Get bundle runtime.
* Get the bundle runtime.
*
* @return string|null
*/
Expand All @@ -125,6 +125,12 @@ public function runtimeSource()
return self::$runtimes[$runtime] = file_get_contents("{$this->path}/{$runtime}");
}

/**
* Get the bundle URL.
*
* @param string $path
* @return string
*/
protected function getUrl($path)
{
if (parse_url($path, PHP_URL_HOST)) {
Expand All @@ -137,6 +143,11 @@ protected function getUrl($path)
return "{$uri}/{$path}";
}

/**
* Set the bundle runtime.
*
* @return void
*/
protected function setRuntime()
{
if (Arr::isAssoc($this->bundle['js'])) {
Expand Down
4 changes: 3 additions & 1 deletion src/Roots/Acorn/Assets/Concerns/Enqueuable.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ public function inlineRuntime()
*/
public function inline($contents, $position = 'after')
{
if (! $handles = array_keys($this->bundle['js'] ?? [])) {
$bundle = array_merge($this->bundle['js'], $this->bundle['mjs']) ?? [];

if (! $handles = array_keys($bundle)) {
return $this;
}

Expand Down