Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Formatting Bug]: 1.38.4 seems to breaks when attributes are not separated by whitespace #878

Closed
vorban opened this issue Oct 16, 2023 · 3 comments · Fixed by #879
Closed
Assignees
Labels
bug Something isn't working

Comments

@vorban
Copy link

vorban commented Oct 16, 2023

Version

1.38.4

Template before formatting

edit: i pasted the wrong clipboard, sorry.

        <button class="m-2.5 h-5 w-5 scale-125 cursor-pointer p-1" data-tippy-content="Modifier la prestation"
            :class="isHovered && !currently_dragging ? 'opacity-100 delay-50' : 'opacity-0 delay-0'"x-data="{ tippyInstance: null }" x-init="tippyInstance = window.tippy($root)" x-on:click="tippyInstance.hide(); $dispatch('open-prestation-modal', {{ $task->id }})">
            @include('svg.misc.tag')
        </button>
        <button class="m-2.5 h-5 w-5 scale-125 cursor-pointer p-1" data-tippy-content="Modifier la durée" :class="isHovered && !currently_dragging ? 'opacity-100 delay-50' : 'opacity-0 delay-0'" x-data="{ tippyInstance: null }" x-init="tippyInstance = window.tippy($root)" x-on:click="tippyInstance.hide(); $dispatch('open-duration-modal', {{ $task->id }})">
            @include('svg.misc.extand')
        </button>
        <button class="m-2.5 h-5 w-5 scale-125 cursor-pointer p-0.5" data-tippy-content="Dupliquer cette tâche" :class="isHovered && !currently_dragging ? 'opacity-100 delay-50' : 'opacity-0 delay-0'" wire:click="duplicate"x-data="{ tippyInstance: null }" x-init="tippyInstance = window.tippy($root)">
            @include('svg.misc.duplicate')
        </button>

Template after formatting

<button class="m-2.5 h-5 w-5 scale-125 cursor-pointer p-1" data-tippy-content="Modifier la prestation"
            :class="isHovered && !currently_dragging ? 'opacity-100 delay-50' :
                'opacity-0 delay-0'"x-data="{ tippyInstance: null }" x-init="tippyInstance = window.tippy($root)" x-on:click="tippyInstance.hide(); $dispatch('open-prestation-modal', {{ $task->id }})">
            @include('svg.misc.tag')
                <
                /button> <
                button class="m-2.5 h-5 w-5 scale-125 cursor-pointer p-1" class ="isHovered && !currently_dragging ? 'opacity-100 delay-50' : 'opacity-0 delay-0'"x data-tippy-content="Modifier la durée":
                -
                data ="{ tippyInstance: null }" x-init="tippyInstance = window.tippy($root)" x-on:click="tippyInstance.hide(); $dispatch('open-duration-modal', {{ $task->id }})" >
                @include('svg.misc.extand') <
                /button> <
                button class="m-2.5 h-5 w-5 scale-125 cursor-pointer p-0.5" data-tippy-content="Dupliquer cette tâche": class ="isHovered
            && !currently_dragging ? 'opacity-100 delay-50' : 'opacity-0 delay-0'" wire:click="duplicate"x-data="{ tippyInstance: null }" x-init="tippyInstance = window.tippy($root)">
            @include('svg.misc.duplicate')
        </button>

Expected Behaviour

The code above is not correctly formatted anymore.

This issue was noticed when we updated vscode-blade-formatter this morning to 0.23.3, which bumps your package from 1.38.3 to 1.38.4.

Behaviour was reproduced with a fresh install of 1.38.4 through npm i -g per your documentation, the diff output is attached.

Relevant log output

$ blade-formatter --version
1.38.4

$ blade-formatter -c -d resources/views/livewire/calendar/task.blade.php

Check formatting...
resources/views/livewire/calendar/task.blade.php

Differences:

path: resources/views/livewire/calendar/task.blade.php:29
--        </button>
++                <
path: resources/views/livewire/calendar/task.blade.php:30
--        <button class="m-2.5 h-5 w-5 scale-125 cursor-pointer p-1" data-tippy-content="Modifier la durée": class ="isHovered
++                /button> <
path: resources/views/livewire/calendar/task.blade.php:31
--            && !currently_dragging ? 'opacity-100 delay-50' : 'opacity-0 delay-0'"x - data ="{ tippyInstance: null }" x-init="tippyInstance = window.tippy($root)" x-on:click="tippyInstance.hide(); $dispatch('open-duration-modal', {{ $task->id }})">
++                button class="m-2.5 h-5 w-5 scale-125 cursor-pointer p-1" class ="isHovered && !currently_dragging ? 'opacity-100 delay-50' : 'opacity-0 delay-0'"x data-tippy-content="Modifier la durée":
path: resources/views/livewire/calendar/task.blade.php:32
--            @include('svg.misc.extand')
++                -
path: resources/views/livewire/calendar/task.blade.php:33
--        </button>
++                data ="{ tippyInstance: null }" x-init="tippyInstance = window.tippy($root)" x-on:click="tippyInstance.hide(); $dispatch('open-duration-modal', {{ $task->id }})" >
path: resources/views/livewire/calendar/task.blade.php:34
--        <button class="m-2.5 h-5 w-5 scale-125 cursor-pointer p-0.5" data-tippy-content="Dupliquer cette tâche" :class="isHovered && !currently_dragging ? 'opacity-100 delay-50' : 'opacity-0 delay-0'" wire:click="duplicate"x-data="{ tippyInstance: null }" x-init="tippyInstance = window.tippy($root)">
++                @include('svg.misc.extand') <
path: resources/views/livewire/calendar/task.blade.php:35
--            @include('svg.misc.duplicate')
++                /button> <
path: resources/views/livewire/calendar/task.blade.php:36
--        </button>
++                button class="m-2.5 h-5 w-5 scale-125 cursor-pointer p-0.5" data-tippy-content="Dupliquer cette tâche": class ="isHovered
path: resources/views/livewire/calendar/task.blade.php:37
--    </div>
++            && !currently_dragging ? 'opacity-100 delay-50' : 'opacity-0 delay-0'" wire:click="duplicate"x-data="{ tippyInstance: null }" x-init="tippyInstance = window.tippy($root)">
path: resources/views/livewire/calendar/task.blade.php:38
--    <div @class([
++            @include('svg.misc.duplicate')
path: resources/views/livewire/calendar/task.blade.php:39
--        'shadow shadow-gray-300 task rounded-md border border-borderMedium py-[10px] px-3 flex flex-col items-start justify-between  bg-white cursor-pointer w-full h-full border-t-[3px]',
++        </button>
path: resources/views/livewire/calendar/task.blade.php:40
--        'opacity-100' => $task->tracking_started_at !== null,
++    </div>
@vorban vorban added the bug Something isn't working label Oct 16, 2023
@vorban
Copy link
Author

vorban commented Oct 16, 2023

Quick update - somehow we missed a detail on the first <button>:

        <button class="m-2.5 h-5 w-5 scale-125 cursor-pointer p-1" data-tippy-content="Modifier la prestation"
            :class="isHovered && !currently_dragging ? 'opacity-100 delay-50' : 'opacity-0 delay-0'"x-data="{ tippyInstance: null }" x-init="tippyInstance = window.tippy($root)" x-on:click="tippyInstance.hide(); $dispatch('open-prestation-modal', {{ $task->id }})">
            @include('svg.misc.tag')
        </button>

x-data is joined with the previous " without spacing.

Adding a space completely fixes the issue.

If this is intended behaviour, this issue can be closed, and I apologize for the mishaps.

@vorban vorban changed the title [Formatting Bug]: 1.38.4 breaks alpinejs directives and html tags [Formatting Bug]: 1.38.4 seems to breaks when attributes are not separated by whitespace Oct 16, 2023
@shufo
Copy link
Owner

shufo commented Oct 16, 2023

Thanks @vorban for reporting the issue.
This is not intended behaviour, so I'll look for into it.

shufo added a commit that referenced this issue Oct 16, 2023
When html tag attributes are not separated by space like class=""foo="",
formatter will output unexpected result

✅ Closes: #878
@shufo
Copy link
Owner

shufo commented Oct 16, 2023

Fixed at https://github.com/shufo/blade-formatter/releases/tag/v1.38.5
Fixed at v0.23.4 on vscode-blade-formatter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants