joshuagruenstein / snooze

A lightweight JS front-end microframework for API-first webapps.
MIT License
1 stars 0 forks source link

jQuery-style DOM selection and manipulation #20

Open joshuagruenstein opened 7 years ago

joshuagruenstein commented 7 years ago

OK, hear me out. I know that's not the kind of library snooze is. But, snooze is supposed to be flexible, and we don't want people to have to also include jQuery. A simple zzz("cssSelector") DOM fetcher and some nice DOM utilities (CSS manipulation, setting escaped text) would be convenient syntactic sugar, and very few LOC. Now, I'm still not sure this is the right thing to do, but I thought I'd make the issue. Thoughts?

truell20 commented 7 years ago

What is wrong with their including JQuery or some other DOM manipulation library if they need DOM manipulation?

truell20 commented 7 years ago

I don't think that this should be shipped in a v1. It is a ton of more work. If people want DOM manipulation, there are a ton of libraries out there. The whole bundling strategy is one of the very things that makes JQuery bad. Results in a bloated library. Not the right philosophy.

joshuagruenstein commented 7 years ago

I see your point. It just feels wrong to ask people to include another library, especially because I'm not 100% confident snooze can handle a full blown webapp on it's own yet. We may need a teensy bit of DOM manipulation to fill in the corners. And I don't think it's a lot more work: for example, here's how I'd implement DOM selection:

function zzz(domQuery) {
    return document.querySelector(domQuery);
}

Just tiny little wrappers and syntactic sugar to make dev lives easier, and to make sure you can finish an app while staying in the snooze environment.

joshuagruenstein commented 7 years ago

We could even provide two releases, one with DOM manipulation and one without. However, I have a feeling the difference in size would be so negligible nobody would use the one without.

truell20 commented 7 years ago

Oops. Didn't mean to close.

truell20 commented 7 years ago

Why does it need to be able to handle a full blown webapp on its own? Large, one library projects are enormously rare. I need two libraries just to run JS unit tests effectively. That's fine. It's nice when libraries focus on what they are good at.