Live data from Hacker News

Weaintfoundshit.js

nicosantangelo.github.io

1–10 of 22 posts

Re: Weaintfoundshit.js

#2
I like the fact that it works with querySelectorAll! This is compatible with my projects in which I do:

    var qsa = function(sel){return document.querySelectorAll(sel)};
However, it does not work with:

    var subqsa = function(el,sel){return el.querySelectorAll(sel);}

Re: Weaintfoundshit.js

#6
I don't understand at all. I clicked "I don't get it," then put ".arbitrary" in as a selector, and.....a message comes up saying "Wasn't that awesome?" Nothing else happened.

What am I missing here

Re: Weaintfoundshit.js

#7

I don't understand at all. I clicked "I don't get it," then put ".arbitrary" in as a selector, and.....a message comes up saying "Wasn't that awesome?" Nothing else happened. What am I missing here

My best guess is you could raise an error and then you would always know if a selector didn't match.

In jQuery, a selector which doesn't match will evaluate to true, where as .length would be 0. This is a source of bugs, I'm sure, especially for beginners.

Re: Weaintfoundshit.js

#8

I don't understand at all. I clicked "I don't get it," then put ".arbitrary" in as a selector, and.....a message comes up saying "Wasn't that awesome?" Nothing else happened. What am I missing here

I believe it's a joke. At least I opened these comments thinking it was a joke akin to VanillaJS framework[1]. querySelectorAll returns an empty array if there are no matches, you don't need fancy string messages or errors for that.

[1] http://vanilla-js.com/

Re: Weaintfoundshit.js

#9

I like the fact that it works with querySelectorAll! This is compatible with my projects in which I do: var qsa = function(sel){return document.querySelectorAll(sel)}; However, it does not work with: var subqsa = function(el,sel){return el.querySelectorAll(sel);}

If you're seriously wondering why is it so then, well, they're just replacing native methods of the document object, in order to get the same behavior from your second line, they'll have to replace Element.prototype.querySelectorAll as well, which is a bad idea.

Re: Weaintfoundshit.js

#10

I don't understand at all. I clicked "I don't get it," then put ".arbitrary" in as a selector, and.....a message comes up saying "Wasn't that awesome?" Nothing else happened. What am I missing here

When I ran it, at least with the UI mode on the website itself, I get a mp4 of Spaceballs.

https://nicosantangelo.github.io/weaintfoundshit.js/interact...

Post reply on HN