Skip to content

Commit b5e6603

Browse files
Jaybuzdriesvints
andauthored
Fix for invalid defer attribute on SVG tag (#218)
* Fix for invalid attribute * wip --------- Co-authored-by: Dries Vints <dries@vints.be>
1 parent 1520ec7 commit b5e6603

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,7 @@ This will push the icons to the stack "bladeicons", you should load this stack a
422422

423423
##### Using deferred icons in JavaScript
424424

425-
You can re-use your icons from blade in your JavaScript rendered views by providing a custom defer value that will be used
426-
as an identifier:
425+
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:
427426

428427
```blade
429428
<x-icon-camera defer="my-custom-hash" />

src/Svg.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ public function __construct(string $name, string $contents, array $attributes =
1919
{
2020
$this->name = $name;
2121
$this->contents = $this->deferContent($contents, $attributes['defer'] ?? false);
22+
23+
unset($attributes['defer']);
24+
2225
$this->attributes = $attributes;
2326
}
2427

tests/SvgTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function it_can_compile_to_defered_html()
3232
$svg = new Svg('heroicon-o-arrow-right', '<svg>'.$svgPath.'</svg>', ['defer' => true]);
3333

3434
$svgHtml = $svg->toHtml();
35-
$this->assertEquals('<svg defer="1"><use href="#icon-8970cc32a6db8f9088d764a8832c411b"></use></svg>
35+
$this->assertEquals('<svg><use href="#icon-8970cc32a6db8f9088d764a8832c411b"></use></svg>
3636
@once("icon-8970cc32a6db8f9088d764a8832c411b")
3737
@push("bladeicons")
3838
<g id="icon-8970cc32a6db8f9088d764a8832c411b">
@@ -49,7 +49,7 @@ public function it_can_compile_to_defered_html_custom_defer()
4949
$svg = new Svg('heroicon-o-arrow-right', '<svg>'.$svgPath.'</svg>', ['defer' => 'my-custom-hash']);
5050

5151
$svgHtml = $svg->toHtml();
52-
$this->assertEquals('<svg defer="my-custom-hash"><use href="#icon-my-custom-hash"></use></svg>
52+
$this->assertEquals('<svg><use href="#icon-my-custom-hash"></use></svg>
5353
@once("icon-my-custom-hash")
5454
@push("bladeicons")
5555
<g id="icon-my-custom-hash">
@@ -67,7 +67,7 @@ public function it_can_compile_to_defered_html_with_group()
6767

6868
$svgHtml = $svg->toHtml();
6969

70-
$this->assertEquals('<svg defer="1"><use href="#icon-17c27df6b7d6560d9202829b719225b0"></use></svg>
70+
$this->assertEquals('<svg><use href="#icon-17c27df6b7d6560d9202829b719225b0"></use></svg>
7171
@once("icon-17c27df6b7d6560d9202829b719225b0")
7272
@push("bladeicons")
7373
<g id="icon-17c27df6b7d6560d9202829b719225b0">
@@ -85,7 +85,7 @@ public function it_can_compile_to_defered_html_with_group_custom_defer()
8585

8686
$svgHtml = $svg->toHtml();
8787

88-
$this->assertEquals('<svg defer="my-custom-hash"><use href="#icon-my-custom-hash"></use></svg>
88+
$this->assertEquals('<svg><use href="#icon-my-custom-hash"></use></svg>
8989
@once("icon-my-custom-hash")
9090
@push("bladeicons")
9191
<g id="icon-my-custom-hash">
@@ -105,7 +105,7 @@ public function it_can_compile_to_defered_html_with_group_and_whitespace()
105105

106106
$svgHtml = $svg->toHtml();
107107

108-
$this->assertEquals('<svg defer="1"><use href="#icon-7f6f192a3c61bd15e25530394ec18d86"></use></svg>
108+
$this->assertEquals('<svg><use href="#icon-7f6f192a3c61bd15e25530394ec18d86"></use></svg>
109109
@once("icon-7f6f192a3c61bd15e25530394ec18d86")
110110
@push("bladeicons")
111111
<g id="icon-7f6f192a3c61bd15e25530394ec18d86">
@@ -127,7 +127,7 @@ public function it_can_compile_to_defered_html_with_mask_tag()
127127

128128
$svgHtml = $svg->toHtml();
129129

130-
$this->assertEquals('<svg defer="1"><use href="#icon-75e079eb3e6f7403d66f76ff7f0475c5"></use></svg>
130+
$this->assertEquals('<svg><use href="#icon-75e079eb3e6f7403d66f76ff7f0475c5"></use></svg>
131131
@once("icon-75e079eb3e6f7403d66f76ff7f0475c5")
132132
@push("bladeicons")
133133
<g id="icon-75e079eb3e6f7403d66f76ff7f0475c5">
@@ -151,7 +151,7 @@ public function it_can_compile_to_defered_html_with_defs_tag()
151151

152152
$svgHtml = $svg->toHtml();
153153

154-
$this->assertEquals('<svg defer="1"><use href="#icon-cf7005271ce6acebfa1a20cb123ad8b0"></use></svg>
154+
$this->assertEquals('<svg><use href="#icon-cf7005271ce6acebfa1a20cb123ad8b0"></use></svg>
155155
@once("icon-cf7005271ce6acebfa1a20cb123ad8b0")
156156
@push("bladeicons")
157157
<g id="icon-cf7005271ce6acebfa1a20cb123ad8b0">
@@ -172,7 +172,7 @@ public function it_can_compile_to_defered_html_with_use_tag()
172172

173173
$svgHtml = $svg->toHtml();
174174

175-
$this->assertEquals('<svg defer="1"><use href="#icon-540a77d3751047fd94004bffda3ffb55"></use></svg>
175+
$this->assertEquals('<svg><use href="#icon-540a77d3751047fd94004bffda3ffb55"></use></svg>
176176
@once("icon-540a77d3751047fd94004bffda3ffb55")
177177
@push("bladeicons")
178178
<g id="icon-540a77d3751047fd94004bffda3ffb55">

0 commit comments

Comments
 (0)