Why Alpine x-data doesn’t react to its own property changes?

There is an input component. Code below.

@props([
'disabled' => false,
'hidden' => false,
'type' => 'text',
'state' => null,
'borderClass' => ''
])

@php
switch ($state){
    case 'alert':
        $borderClass = 'border-2 border-red-600';
        break;
    case 'success':
        $borderClass = 'border-2 border-green-600';
        break;
}

@endphp

<input x-data="{
    borderClass: @js($borderClass),
    removeBorderClass() {

        // for testing
        document.querySelectorAll('[x-data]').forEach(el => {
            console.log(el);
        });
        console.log(document.getElementById('title'));
        // end for testing

        if (@js($borderClass)){
            let classes = this.borderClass.split(' ');
            $refs.input.classList.remove(...classes);
        }
    }
}"
    x-ref="input"
    x-on:focus="removeBorderClass()"

    value = "{{ $slot ?? '' }}"
    type = "{{ $type }}"
    {{ $disabled ? 'disabled' : '' }}
    {{ $hidden ? 'hidden' : '' }}
    {{ $attributes->merge(['class' => 'focus:ring-indigo-600 focus:border-indigo-600 focus:border shadow-sm sm:text-sm rounded-md border-gray-300 ' . $borderClass]) }}
 >

After changing $state property and the $borderClass property, I get changes on the screen with border color, i.e. border-2 border-red-600 is added to DOM, but I don’t get any change for alpine when calling x-on:focus=removeBorderClass()

I have decided to test the result and implement console.log in method by using two different ways to get the same DOM element. 1. by ‘x-data’ selector and by ‘id’

    // for testing
    document.querySelectorAll('[x-data]').forEach(el => {
        console.log(el);
    });
    console.log(document.getElementById('title'));
    // end for testing

Here is the result from browser devtools. For

1.

document.querySelectorAll('[x-data]').forEach(el => {
                console.log(el);
            });

Result (only part for our input element):

<input x-data="{
    borderClass: '',
    removeBorderClass() {

        // for testing
        document.querySelectorAll('[x-data]').forEach(el => {
            console.log(el);
        });
        console.log(document.getElementById('title'));
        // end for testing

        if (''){
            let classes = this.borderClass.split(' ');
            $refs.input.classList.remove(...classes);
        }
    }
}" x-ref="input" x-on:focus="removeBorderClass()" value="" type="text" class="focus:ring-indigo-600 focus:border-indigo-600 focus:border shadow-sm sm:text-sm rounded-md border-gray-300  w-full" style="margin-right: -2.75rem;" name="depth" wire:model.lazy="depth" placeholder="0" title="depth">
console.log(document.getElementById('title'));

Result:

<input x-data="{
    borderClass: 'border-2 border-red-600',
    removeBorderClass() {

        // for testing
        document.querySelectorAll('[x-data]').forEach(el => {
            console.log(el);
        });
        console.log(document.getElementById('title'));
        // end for testing

        if ('border-2 border-red-600'){
            let classes = this.borderClass.split(' ');
            $refs.input.classList.remove(...classes);
        }
    }
}" x-ref="input" x-on:focus="removeBorderClass()" value="" type="text" class="focus:ring-indigo-600 focus:border-indigo-600 focus:border shadow-sm sm:text-sm rounded-md border-gray-300 border-2 border-red-600 w-full" wire:model.lazy="title" name="title" id="title">

Why they are different. Why while calling the same element get different results? How get changes with alpine?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật