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

Browser Compatibility Issue: querySelector(':has()') Not Supported in Older Browsers #886

Open
3 tasks done
elbaylot opened this issue Dec 18, 2024 · 0 comments
Open
3 tasks done

Comments

@elbaylot
Copy link

Flux version

v1.1.0

Livewire version

v3.5.17

What is the problem?

Description

The current implementation of the button() method in select.js uses the CSS :has() pseudo-class which isn't supported in older versions of Chrome and other browsers. This causes a DOMException when trying to find a button that has a popover element as its next sibling.

Error message:

CopyUncaught DOMException: Failed to execute 'querySelector' on 'Element': 'button:has(+ [popover])' is not a valid selector.

bug video :

  • Nothing happen when user click on the select
Enregistrement.de.l.ecran.2024-12-18.a.09.06.40.mov

Code snippets

Current implementation:

livewire/flux-pro/js/select.js:270

button() {
    // @todo: fix this:
    return this.querySelector('button:has(+ [popover])')
}

Proposed solution :

button() {
    const buttons = this.querySelectorAll('button');

    return Array.from(buttons).find(button => {
        const nextElement = button.nextElementSibling;
        return nextElement && nextElement.hasAttribute('popover');
    });
}

How do you expect it to work?

  • The selector should work across all supported browsers (including older versions)

Please confirm (incomplete submissions will not be addressed)

  • I have provided easy and step-by-step instructions to reproduce the bug.
  • I have provided code samples as text and NOT images.
  • I understand my bug report will be closed if I haven't met the criteria above.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant