Skip to content

"defer" attribute fails #194

Open
Open
@beeards

Description

Library version

v1.3.0

Laravel version

v9.18.0

PHP version

v8.1.7

Description

defer it's not working as expected with the helper function. I have the components deactivated, but even activated it fails. And the sets enabled too.

// helpers.php
function svg(string $name, $class = '', array $attributes = []): Svg

Steps to reproduce

// config/blade-icons.php
return [
    // ...
    'sets' => [
        'default' => [
            'paths' => [
                'resources/svg',
                'vendor/blade-ui-kit/blade-heroicons/resources/svg',
            ],
            'disk' => '',
            'prefix' => 'icon',
            'fallback' => '',
            'class' => '',
            'attributes' => [],
        ],
    ],
    // ...
];

Method 1

{{-- home.blade.php --}}
{{ svg('o-home', 'method-A', ['defer']) }}
{{ svg('o-home', 'method-B', ['defer' => true]) }}
{{ svg('o-home', 'method-C', ['defer' => 1]) }}
{{ svg('o-home', 'method-D', ['defer' => '1']) }}
{{ svg('o-home', ['class' => 'method-E'], ['defer']) }}
{{ svg('o-home', ['class' => 'method-F'], ['defer' => true]) }}
{{ svg('o-home', ['class' => 'method-G'], ['defer' => 1]) }}
{{ svg('o-home', ['class' => 'method-H'], ['defer' => '1']) }}
{{ svg('o-home', ['class' => 'method-I', 'defer']) }}
{{ svg('o-home', ['class' => 'method-J', 'defer' => true]) }}
{{ svg('o-home', ['class' => 'method-K', 'defer' => 1]) }}
{{ svg('o-home', ['class' => 'method-L', 'defer' => '1']) }}
<!-- - - - - - - - - -->
@stack('bladeicons')

outputs

<!-- localhost/home -->
<svg defer class="method-A" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"/></svg>

<svg defer="1" class="method-B" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><use href="#icon-08184c0014ea88c93d292d37d36a0a53"></use></svg>
@once("icon-08184c0014ea88c93d292d37d36a0a53")
    @push("bladeicons")
    <g id="icon-08184c0014ea88c93d292d37d36a0a53"><path stroke-linecap="round" stroke-linejoin="round" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"/></g>
    @endpush
@endonce

<svg defer="1" class="method-C" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><use href="#icon-08184c0014ea88c93d292d37d36a0a53"></use></svg>
@once("icon-08184c0014ea88c93d292d37d36a0a53")
    @push("bladeicons")
    <g id="icon-08184c0014ea88c93d292d37d36a0a53"><path stroke-linecap="round" stroke-linejoin="round" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"/></g>
    @endpush
@endonce

<svg defer="1" class="method-D" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><use href="#icon-08184c0014ea88c93d292d37d36a0a53"></use></svg>
@once("icon-08184c0014ea88c93d292d37d36a0a53")
    @push("bladeicons")
    <g id="icon-08184c0014ea88c93d292d37d36a0a53"><path stroke-linecap="round" stroke-linejoin="round" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"/></g>
    @endpush
@endonce

<svg class="method-E" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"/></svg>

<svg class="method-F" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"/></svg>

<svg class="method-G" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"/></svg>

<svg class="method-H" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"/></svg>

<svg class="method-I" defer xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"/></svg>

<svg class="method-J" defer="1" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><use href="#icon-08184c0014ea88c93d292d37d36a0a53"></use></svg>
@once("icon-08184c0014ea88c93d292d37d36a0a53")
    @push("bladeicons")
    <g id="icon-08184c0014ea88c93d292d37d36a0a53"><path stroke-linecap="round" stroke-linejoin="round" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"/></g>
    @endpush
@endonce

<svg class="method-K" defer="1" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><use href="#icon-08184c0014ea88c93d292d37d36a0a53"></use></svg>
@once("icon-08184c0014ea88c93d292d37d36a0a53")
    @push("bladeicons")
    <g id="icon-08184c0014ea88c93d292d37d36a0a53"><path stroke-linecap="round" stroke-linejoin="round" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"/></g>
    @endpush
@endonce

<svg class="method-L" defer="1" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><use href="#icon-08184c0014ea88c93d292d37d36a0a53"></use></svg>
@once("icon-08184c0014ea88c93d292d37d36a0a53")
    @push("bladeicons")
    <g id="icon-08184c0014ea88c93d292d37d36a0a53"><path stroke-linecap="round" stroke-linejoin="round" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"/></g>
    @endpush
@endonce
<!-- - - - - - - - - -->
<svg hidden class="hidden">
</svg>

Method 2

// config/blade-icons.php
return [
    // ...
    'attributes' => [
        'defer' => true,
    ],
    // ...
];
{{-- home.blade.php --}}
{{ svg('o-home', ['class' => 'method-M']) }}
{{ svg('o-home', 'method-N') }}
<!-- - - - - - - - - -->
@stack('bladeicons')

outputs

<svg class="method-M" defer="1" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><use href="#icon-08184c0014ea88c93d292d37d36a0a53"></use></svg>
@once("icon-08184c0014ea88c93d292d37d36a0a53")
@push("bladeicons")
<g id="icon-08184c0014ea88c93d292d37d36a0a53"><path stroke-linecap="round" stroke-linejoin="round" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"/></g>
@endpush
@endonce

<svg class="method-N" defer="1" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true"><use href="#icon-08184c0014ea88c93d292d37d36a0a53"></use></svg>
@once("icon-08184c0014ea88c93d292d37d36a0a53")
@push("bladeicons")
<g id="icon-08184c0014ea88c93d292d37d36a0a53"><path stroke-linecap="round" stroke-linejoin="round" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"/></g>
@endpush
@endonce

<!-- - - - - - - - - -->
<svg hidden class="hidden">
</svg>

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions