From 8270edbc7842662e5403fbc1789b3649117e09fd Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Thu, 21 Jan 2016 21:24:26 +0100 Subject: [PATCH 1/4] Fix loading js and css from collections Calling add() lose information on - CSS: $group - JS: $loading, $group --- system/src/Grav/Common/Assets.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/src/Grav/Common/Assets.php b/system/src/Grav/Common/Assets.php index d8dd0ae26..ac096080e 100644 --- a/system/src/Grav/Common/Assets.php +++ b/system/src/Grav/Common/Assets.php @@ -251,7 +251,7 @@ class Assets } return $this; } elseif (isset($this->collections[$asset])) { - $this->add($this->collections[$asset], $priority, $pipeline, $group); + $this->addCss($this->collections[$asset], $priority, $pipeline, $group); return $this; } @@ -309,7 +309,7 @@ class Assets } return $this; } elseif (isset($this->collections[$asset])) { - $this->add($this->collections[$asset], $priority, $pipeline, $loading, $group); + $this->addJs($this->collections[$asset], $priority, $pipeline, $loading, $group); return $this; } From 774cf2d6d01731950e4b41ebf0af92b996276fc7 Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Fri, 22 Jan 2016 00:09:14 +0100 Subject: [PATCH 2/4] Recreated an issue in calling with an array of values `{% do assets.addJs('jquery', {'loading':'async'}) %}` introduced in https://github.com/getgrav/grav/commit/d5bd99b363ec955a90bf50f9f8856a819bec31bf --- system/src/Grav/Common/Assets.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/system/src/Grav/Common/Assets.php b/system/src/Grav/Common/Assets.php index ac096080e..1703470a2 100644 --- a/system/src/Grav/Common/Assets.php +++ b/system/src/Grav/Common/Assets.php @@ -251,7 +251,7 @@ class Assets } return $this; } elseif (isset($this->collections[$asset])) { - $this->addCss($this->collections[$asset], $priority, $pipeline, $group); + $this->add($this->collections[$asset], $priority, $pipeline, $group); return $this; } @@ -273,7 +273,7 @@ class Assets ]; // check for dynamic array and merge with defaults - if (func_num_args() == 2) { + if (func_num_args() == 3) { $dynamic_arg = func_get_arg(1); if (is_array($dynamic_arg)) { $data = array_merge($data, $dynamic_arg); @@ -309,7 +309,7 @@ class Assets } return $this; } elseif (isset($this->collections[$asset])) { - $this->addJs($this->collections[$asset], $priority, $pipeline, $loading, $group); + $this->add($this->collections[$asset], $priority, $pipeline, $loading, $group); return $this; } @@ -332,7 +332,7 @@ class Assets ]; // check for dynamic array and merge with defaults - if (func_num_args() == 2) { + if (func_num_args() == 3) { $dynamic_arg = func_get_arg(1); if (is_array($dynamic_arg)) { $data = array_merge($data, $dynamic_arg); From 77c8458fbf1d729821c86fed9c9a51ed128ec693 Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Fri, 22 Jan 2016 10:43:41 +0100 Subject: [PATCH 3/4] :bug: Fix addJs and addCSS problem Changes supported by tests in https://github.com/getgrav/grav/commit/27af9432e0fa9a7abb2b6a2e3f3a6f6d1 55a37e9 --- system/src/Grav/Common/Assets.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system/src/Grav/Common/Assets.php b/system/src/Grav/Common/Assets.php index 1703470a2..d649979d9 100644 --- a/system/src/Grav/Common/Assets.php +++ b/system/src/Grav/Common/Assets.php @@ -273,7 +273,7 @@ class Assets ]; // check for dynamic array and merge with defaults - if (func_num_args() == 3) { + if (func_num_args() > 1) { $dynamic_arg = func_get_arg(1); if (is_array($dynamic_arg)) { $data = array_merge($data, $dynamic_arg); @@ -332,10 +332,10 @@ class Assets ]; // check for dynamic array and merge with defaults - if (func_num_args() == 3) { + if (func_num_args() > 1) { $dynamic_arg = func_get_arg(1); if (is_array($dynamic_arg)) { - $data = array_merge($data, $dynamic_arg); + $data = array_merge($data, $dynamic_arg); } } From 684503245c255cff509e75e8bff715516bb99e5c Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Fri, 22 Jan 2016 12:59:22 +0100 Subject: [PATCH 4/4] Call addCss & addJs instead of add(), as otherwise it will lose group and loading information --- system/src/Grav/Common/Assets.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/src/Grav/Common/Assets.php b/system/src/Grav/Common/Assets.php index d649979d9..2da3eafe1 100644 --- a/system/src/Grav/Common/Assets.php +++ b/system/src/Grav/Common/Assets.php @@ -251,7 +251,7 @@ class Assets } return $this; } elseif (isset($this->collections[$asset])) { - $this->add($this->collections[$asset], $priority, $pipeline, $group); + $this->addCss($this->collections[$asset], $priority, $pipeline, $group); return $this; } @@ -309,7 +309,7 @@ class Assets } return $this; } elseif (isset($this->collections[$asset])) { - $this->add($this->collections[$asset], $priority, $pipeline, $loading, $group); + $this->addJs($this->collections[$asset], $priority, $pipeline, $loading, $group); return $this; }