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

replaced input[class=single-mode] with input.single-mode #41

Merged
merged 1 commit into from
Sep 24, 2023

Conversation

ivanminutillo
Copy link
Contributor

Hello, I am experiencing this very weird error since some time now using live_select

live_select.min.js:24 Uncaught TypeError: Cannot read properties of null (reading 'dispatchEvent')
    at ViewHook.inputEvent (live_select.min.js:24:40)
    at live_select.min.js:24:526
    at callbackRef (view_hook.js:43:65)
    at Object.dispatchEvent (dom.js:335:12)
    at LiveSocket.dispatchEvent (live_socket.js:737:9)
    at live_socket.js:741:47
    at Array.forEach (<anonymous>)
    at LiveSocket.dispatchEvents (live_socket.js:741:12)
    at View.update (view.js:527:21)
    at view.js:600:68

After some debugging I found that this line https://github.com/maxmarcon/live_select/blob/main/assets/js/live_select.js#L81 don't return the input node (when single-mode is selected).
But if I replace input[class=single-mode] with input.single-mode the issue is solved. I'm aware that using the attr syntax with classes is risky (eg. it does work only if the order of the classes differs and it's less performant than using class-based selectors...

@maxmarcon
Copy link
Owner

Thank you for spotting and fixing this! No idea what I was thinking when I wrote that nonsense. I must have been tired :)

@maxmarcon maxmarcon merged commit 759f57c into maxmarcon:main Sep 24, 2023
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants