diff --git a/src/Svg.php b/src/Svg.php index 277dcb8..2c02454 100644 --- a/src/Svg.php +++ b/src/Svg.php @@ -47,7 +47,7 @@ protected function deferContent(string $contents, $defer = false): string return $contents; } - $svgContent = strip_tags($contents, ['circle', 'ellipse', 'line', 'path', 'polygon', 'polyline', 'rect', 'g']); + $svgContent = strip_tags($contents, ['circle', 'ellipse', 'line', 'path', 'polygon', 'polyline', 'rect', 'g', 'mask', 'defs', 'use']); $hash = 'icon-'.(is_string($defer) ? $defer : md5($svgContent)); $contents = str_replace($svgContent, strtr('', [':href' => '#'.$hash]), $contents); $contents .= <<'.$svgPath.'', ['defer' => true]); + + $svgHtml = $svg->toHtml(); + + $this->assertEquals(' + @once("icon-e993fd00a973c62bf85d410a1a01dfe9") + @push("bladeicons") + + + + + + + @endpush + @endonce', $svgHtml); + } + + /** @test */ + public function it_can_compile_to_defered_html_with_defs_tag() + { + $svgPath = ' + + + + +'; + $svg = new Svg('heroicon-o-arrow-right', ''.$svgPath.'', ['defer' => true]); + + $svgHtml = $svg->toHtml(); + + $this->assertEquals(' + @once("icon-50715b5a52a453df06f228c92c5882b1") + @push("bladeicons") + + + + + + + + + @endpush + @endonce', $svgHtml); + } + + /** @test */ + public function it_can_compile_to_defered_html_with_use_tag() + { + $svgPath = ' +'; + $svg = new Svg('heroicon-o-arrow-right', ''.$svgPath.'', ['defer' => true]); + + $svgHtml = $svg->toHtml(); + + $this->assertEquals(' + @once("icon-7f8be00eb404e323e6b73eb94cf8a0d7") + @push("bladeicons") + + + + + @endpush + @endonce', $svgHtml); + } + /** @test */ public function it_can_compile_with_attributes() {