Quote:
Originally Posted by gaming_mouse
i think a bunch of you guys would love the philosophy behind it, and the author, James Halliday, makes an eloquent case here for shoe lace's jquery hate.
i'm on board with minimizing dependencies and avoiding versioning hell. i also favor using generic variants over technology-specific variants[1], so the examples like this seem useful:
Code:
To query for elements based on css selectors, instead of:
$('.foo .bar')
to get a single element, do:
document.querySelector('.foo .bar')
and to get a list of elements do:
document.querySelectorAll('.foo .bar')
the generic form has the additional advantage of being more readable (if a bit wordy) imo.
but then he includes an example like this:
Code:
To set css styles, instead of:
$(element).css(name, value)
you can do:
element.style[name] = value
This should work in all browsers but note that you'll sometimes need to attach the element to the document body before its style property will be set. You can if (!element.style) element.style = {} to get around that.
this kind of nonsense is one of the main problems that jquery solves, so this seems like an example of when *not* to use the generic form.
[1] i probably posted it before but i made a colleague buy me coffee after his choice to use mysql-only `if` instead of supported-by-everyone `case` lost me an hour when the integration test i was writing -- running in sqlite -- didn't work.
(no, i don't want to debate the validity of integration tests that use a different db technology, kthx
)