News for hackers. Stuff that matters.
Re:JQuery 1.8b1: what’s new? by agildehaus on Friday June 22, 2012 @05:01PM (#4148780)
I suppose you write all your code in assembly too? There's no room for going higher-level than the APIs exposed by the browser?
Re:JQuery 1.8b1: what’s new? by MatthewPhillips on Friday June 22, 2012 @06:42PM (#4149254)
I'm just curious what the higher-level APIs are that people need from jQuery that aren't available on mobile. I recall jQuery being popular for selector queries (available on all mobile browsers natively with querySelector and querySelectorAll) and for even listeners (offers no real advantage over addEventListener as far as I can tell).
Re:JQuery 1.8b1: what’s new? by mark_story on Friday June 22, 2012 @09:28PM (#4149753)
Well one nice affordance jQuery offers, is you can do manipulations en-mass without having to write out a loop, or use Array.forEach(). This helps simplify event binding and manipulation code. Also there are selectors in jQuery that are not available in querySelectorAll. And lastly querySelectorAll has some pretty buggy implementations. jQuery smoothes these out.
Re:JQuery 1.8b1: what’s new? by gildas on Saturday June 23, 2012 @06:28AM (#4150536)
Binding event handlers in a loop is an anti-pattern greatly promoted by jQuery during several years. You should use event delegation.
Re:JQuery 1.8b1: what’s new? by mark_story on Saturday June 23, 2012 @11:42AM (#4151041)
Sure but $('.clicky').on('click', doSomething); means no loops at all, and will bind events to all matching elements. I don't think there is a native API way to do this.

Edit: typos

Re:JQuery 1.8b1: what’s new? by gildas on Saturday June 23, 2012 @08:19PM (#4152198)
As far as I know jQuery is written with "native API", so there is obviously a way to do this in JavaScript.

    document.body.addEventListener("click", function(e) { 
      if (e.target.className == "clicky") {
        doSomething();
      }
    }, false);
Re:JQuery 1.8b1: what’s new? by MatthewPhillips on Saturday June 23, 2012 @05:11PM (#4151812)
document.getElementsByClassName('clicky').forEach(function(el) { el.addEventListener('click', doSomething); });
Re:JQuery 1.8b1: what’s new? by d4n3 on Sunday June 24, 2012 @03:53AM (#4152864)
I'm not sure that works. getElementsByClassName (and Id and querySelector) returns a NodeList, not an Array, so there's no foreach, you have to convert it to an array first.
Re:JQuery 1.8b1: what’s new? by MatthewPhillips on Sunday June 24, 2012 @09:02AM (#4153230)
Array.prototype.slice.call(document.getElementsBy....
Re:JQuery 1.8b1: what’s new? by mark_story on Wednesday June 27, 2012 @08:27PM (#4169901)
That's also a ton of tying and a lot of code that a minifier can't reduce. I guess its possible, but do you really want to writing such verbose code?
Re:JQuery 1.8b1: what’s new? by mkmcdonald on Friday June 22, 2012 @05:04PM (#4148787)
The DOM API is clear enough that silly abstractions like "selector engines" are unnecessary.

The C vs. Assembly argument is such a silly non-point; apples and artichokes.

Re:JQuery 1.8b1: what’s new? by nilliams on Friday June 22, 2012 @05:35PM (#4148941)
Selector engines are clearly not silly abstractions otherwise all major browsers would not have implemented querySelectorAll.
Re:JQuery 1.8b1: what’s new? by MatthewPhillips on Friday June 22, 2012 @06:40PM (#4149249)
But since they did, why use jQuery on mobile when 100% of mobile browsers support querySelectorAll?
Re:JQuery 1.8b1: what’s new? by mkmcdonald on Friday June 22, 2012 @06:17PM (#4149132)
…which is a façade for the existing CSS engine. Developers clamoured for it (right or wrong), and it was implemented.
Re:JQuery 1.8b1: what’s new? by taligent on Friday June 22, 2012 @06:35PM (#4149228)
Hilarious that you think that one of the core features of the most successful JS library in history is a "silly abstraction".

And JQuery is much more than just a selector engine.