choojs / choo

:steam_locomotive::train: - sturdy 4kb frontend framework
https://choo.io/
MIT License
6.78k stars 595 forks source link

Could not query selector id with hypen #692

Closed anonimusprogramus closed 5 years ago

anonimusprogramus commented 5 years ago

Expected behavior

Appication attached into div with id with hypen (#app-content)

Actual behavior

Error on console: choo.mount: could not query selector: #app-content

But without hypen (#appcontent), it works.

Steps to reproduce behavior

index.html

<body>
  <div class="wrapper">
    <div class="content-wrapper" id="app-content">
    </div>
  </div>
</body>

index.js

app.route('/', require('./views/main'))
module.exports = app.mount('#app-content')
marlun commented 5 years ago

I think we need more information to solve this. I've tried doing the same in this glitch project and it seem to be working for me: https://glitch.com/edit/#!/accessible-chinchilla see any differences that could cause your problem?

anonimusprogramus commented 5 years ago

Sorry for incomplete information.

I tried yours at glitch and no problem.

But I still encounter that error on localhost which was created with create-choo-app ( version 1.12.3), running on Arch Linux.

If you don't mind checking, please.

Thanks

anonimusprogramus commented 5 years ago

I think I've found the cause. It's bankai that complained couldn't find the node requested by the query selector because it wasn't ready yet.

Tried using document-ready package and did app.mount inside it. Result: bankai complained.

Tried using DOMContentLoaded and did app.mount inside it. Result: OK.

So, (1) the hypen was not the issue. (2) perhaps I should addres this to bankai repo.

Thanks

marlun commented 5 years ago

Choo itself uses documentReady which in turn listens for DOMContentLoaded event so it should work without you having to do any of that. If you can debug enough to locate where bankai is doing something wrong, please close this issue and open another one in the bankai repo.