From 12ca443cb4ed8b45cbbb2c01f6c7c883bb0c38f6 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 28 Apr 2016 10:20:35 -0600 Subject: [PATCH] Fixed async loading on assets pipeline output --- CHANGELOG.md | 6 ++++++ system/src/Grav/Common/Assets.php | 14 ++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a832deff..10fe80081 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v1.1.0-beta.3 +## xx/xx/2016 + +1. [](#bugfix) + * Fixed handling of `{'loading':'async'}` with Assets Pipeline + # v1.1.0-beta.2 ## 04/27/2016 diff --git a/system/src/Grav/Common/Assets.php b/system/src/Grav/Common/Assets.php index dc72102a1..e08ec3425 100644 --- a/system/src/Grav/Common/Assets.php +++ b/system/src/Grav/Common/Assets.php @@ -1005,7 +1005,7 @@ class Assets protected function isRemoteLink($link) { $base = Grav::instance()['uri']->rootUrl(true); - + // sanity check for local URLs with absolute URL's enabled if (Utils::startsWith($link, $base)) { return false; @@ -1042,6 +1042,7 @@ class Assets protected function attributes(array $attributes) { $html = ''; + $no_key = ['loading']; foreach ($attributes as $key => $value) { // For numeric keys we will assume that the key and the value are the same @@ -1054,7 +1055,12 @@ class Assets $value = implode(' ', $value); } - $element = $key . '="' . htmlentities($value, ENT_QUOTES, 'UTF-8', false) . '"'; + if (in_array($key, $no_key)) { + $element = htmlentities($value, ENT_QUOTES, 'UTF-8', false); + } else { + $element = $key . '="' . htmlentities($value, ENT_QUOTES, 'UTF-8', false) . '"'; + } + $html .= ' ' . $element; } @@ -1114,8 +1120,8 @@ class Assets $file = $this->cssRewrite($file, $relative_dir); } - $file = rtrim($file) . PHP_EOL; - $buffer .= $file; + $file = rtrim($file) . PHP_EOL; + $buffer .= $file; } // Pull out @imports and move to top