4 ms·
Why would you use this over normal querySelector{All}? Also, why do you define a window.typeOf global? It completely defeats the purpose of using a clousure. Y
by Sephr 16y ago
Why would you use this over normal querySelector{All}? Also, why do you define a window.typeOf global? It completely defeats the purpose of using a clousure.
You also seem to be checking `typeof value.length == 'number' && typeof value.splice != 'undefined' && !value.propertyIsEnumerable('length')` to determine if something is an Array. First of all, the recommended practice is to check Object.prototype.toString.call(value) === "[object Array]", but since you're going to rely on latest browsers supporting querySelector{All}, you might as well use Array.isArray.
I'm sorry for being so harsh, but this is the most worthless library I have ever seen. You're adding an extremely thin and pointless layer of abstraction to querySelectorAll and polluting the global namespace with four globals, three of which are completely identitcal, and two of which take too much effort to type. Not to mention your use of worst practices (such as using eval(), only loose comparisons, wrapping all of your code in try..catch statements instead of just not doing things that will throw errors, etc.) and your prototypical pollution in Array, Document, and Element. For example, you define Array.prototype.flatten for internal use. You shouldn't pollute global prototypes for something that you can do privately.
- GrooveStomp 16y agoI think you bring up valid points, but you should work on delivery. Your post is very offensive to read, even from someone who has no stake in this library whatsoever - even though I think you're right. You've also got a lot of typos. So, try to be helpful and encouraging instead of damning and dismissive? I'd appreciate that, and be more open to what you're saying.
- Klonoar 16y agoHis delivery is exactly what anybody is bound to get on the internet, and there's seriously nothing wrong with it. If you have an issue with brutal criticism like that, you should re-evaluate even spending time on this site. This is, quite simply, the most _useless_ and badly written 'library' I've seen in some time. I applaud the author for pushing his work out there, but this is the part where you take criticism and run with it, fix it. Listen to Sephr, he's spot on.
- Sephr 16y agoIf my criticism is too forgiving, he may just brush it off and not take any action regarding it. I feel that he needed more brutal criticism so he might take some time to learn the "good" way to write JavaScript for any of his future projects.
- DTrejo 16y agoOuch. There is value in being able to handle extremely harsh criticism. There is also value in being able to say things nicely, with the knowledge that your words will be more easily heard by the person on the other end, and put to use rather than dismissed out of anger.
- Klonoar 16y agoThere's also value in being right, which he definitely is. Whether anyone likes it or not, brutal honesty pushes everything forward.
- swaits 16y agoThere is also value in not being a complete asshole about it. Especially when you're right.
- pg 16y agoBrutal honesty doesn't push things forward any faster than honesty.
- Klonoar 16y agoBrutal honesty places an impetus on the person being criticized to either fight back and prove why they're right, or to fix their code quicker. Honesty without a push is just a statement and nothing more.
- paraschopra 16y agoThis may be irrelevant to original comment but does querySelector work in all modern browsers? My understanding was that it doesn't and so there is need for CSS selector engines like jQuery's sizzle.
- zootm 16y agoI wondered the same thing so let me save you the search: > http://help.dottoro.com/ljlumkqh.php http://help.dottoro.com/ljlumkqh.php The page implies that there is limitations to the IE8 implementation, and that it's only available in relatively recent browsers. In addition, I believe that sizzle implements a set of selectors larger than most or all browsers support natively, although this I am less sure of; the Sizzle documentation certainly implies it strongly: > https://github.com/jeresig/sizzle/wiki https://github.com/jeresig/sizzle/wiki
- tsenart 16y agoEven tough he is being harsh I guess he is right. I am not a ninja Javascript programmer and this is my first library. Thanks for the tips. I have a lot to learn. Also, this is a toy project made in one night that I had no internet access. If you don't like it, don't use it. I'm not selling it as the ultimate solution to all problems. It's my personal play and I learned with it and had no intentions of being so serious. If you noticed, I have the following on the README.md: "I'm sleepy. Don't know if this is too useful yet... Playing with Unicorns.(Unicodes)"
- tsenart 16y agoPlease fork. Let me know those good practices.