Skip to content

Commit

Permalink
fix: prevent double adding of assets
Browse files Browse the repository at this point in the history
This happened when assets where rendered manually via ->render()
  • Loading branch information
BernhardBaumrock committed Jun 7, 2023
1 parent fc3d1ae commit 14b9b10
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion classes/AssetsArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AssetsArray extends \ProcessWire\WireArray
public $minify = false;
public $name;
public $noNewLine = false;

public $rendered = false;

public function __construct(string $name)
{
Expand Down
3 changes: 3 additions & 0 deletions classes/ScriptsArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ class ScriptsArray extends AssetsArray

public function render($options = [])
{
if ($this->rendered) return;
$this->rendered = true;

if (is_string($options)) $options = ['indent' => $options];

// setup options
Expand Down
3 changes: 3 additions & 0 deletions classes/StylesArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ public function postCSS($asset)

public function render($options = [])
{
if ($this->rendered) return;
$this->rendered = true;

if (is_string($options)) $options = ['indent' => $options];

// setup options
Expand Down

0 comments on commit 14b9b10

Please sign in to comment.