diff --git a/README.md b/README.md index 66b54a8..b5b3fec 100644 --- a/README.md +++ b/README.md @@ -422,8 +422,7 @@ This will push the icons to the stack "bladeicons", you should load this stack a ##### Using deferred icons in JavaScript -You can re-use your icons from blade in your JavaScript rendered views by providing a custom defer value that will be used -as an identifier: +You can re-use your icons from blade in your JavaScript rendered views by providing a custom defer value that will be used as an identifier: ```blade diff --git a/src/Svg.php b/src/Svg.php index 704d043..636246b 100644 --- a/src/Svg.php +++ b/src/Svg.php @@ -19,6 +19,9 @@ public function __construct(string $name, string $contents, array $attributes = { $this->name = $name; $this->contents = $this->deferContent($contents, $attributes['defer'] ?? false); + + unset($attributes['defer']); + $this->attributes = $attributes; } diff --git a/tests/SvgTest.php b/tests/SvgTest.php index b9af5e8..78f64b0 100644 --- a/tests/SvgTest.php +++ b/tests/SvgTest.php @@ -32,7 +32,7 @@ public function it_can_compile_to_defered_html() $svg = new Svg('heroicon-o-arrow-right', ''.$svgPath.'', ['defer' => true]); $svgHtml = $svg->toHtml(); - $this->assertEquals(' + $this->assertEquals(' @once("icon-8970cc32a6db8f9088d764a8832c411b") @push("bladeicons") @@ -49,7 +49,7 @@ public function it_can_compile_to_defered_html_custom_defer() $svg = new Svg('heroicon-o-arrow-right', ''.$svgPath.'', ['defer' => 'my-custom-hash']); $svgHtml = $svg->toHtml(); - $this->assertEquals(' + $this->assertEquals(' @once("icon-my-custom-hash") @push("bladeicons") @@ -67,7 +67,7 @@ public function it_can_compile_to_defered_html_with_group() $svgHtml = $svg->toHtml(); - $this->assertEquals(' + $this->assertEquals(' @once("icon-17c27df6b7d6560d9202829b719225b0") @push("bladeicons") @@ -85,7 +85,7 @@ public function it_can_compile_to_defered_html_with_group_custom_defer() $svgHtml = $svg->toHtml(); - $this->assertEquals(' + $this->assertEquals(' @once("icon-my-custom-hash") @push("bladeicons") @@ -105,7 +105,7 @@ public function it_can_compile_to_defered_html_with_group_and_whitespace() $svgHtml = $svg->toHtml(); - $this->assertEquals(' + $this->assertEquals(' @once("icon-7f6f192a3c61bd15e25530394ec18d86") @push("bladeicons") @@ -127,7 +127,7 @@ public function it_can_compile_to_defered_html_with_mask_tag() $svgHtml = $svg->toHtml(); - $this->assertEquals(' + $this->assertEquals(' @once("icon-75e079eb3e6f7403d66f76ff7f0475c5") @push("bladeicons") @@ -151,7 +151,7 @@ public function it_can_compile_to_defered_html_with_defs_tag() $svgHtml = $svg->toHtml(); - $this->assertEquals(' + $this->assertEquals(' @once("icon-cf7005271ce6acebfa1a20cb123ad8b0") @push("bladeicons") @@ -172,7 +172,7 @@ public function it_can_compile_to_defered_html_with_use_tag() $svgHtml = $svg->toHtml(); - $this->assertEquals(' + $this->assertEquals(' @once("icon-540a77d3751047fd94004bffda3ffb55") @push("bladeicons")