cerebralideas / phi-polyfill

A polyfill library for phi.
0 stars 0 forks source link

Rather than using $, I'd like to use phi && use jQuery if available #2

Open cerebrl opened 11 years ago

cerebrl commented 11 years ago

Rather than using what has been tightly associated with jQuery, I'd like to use 'phi'. So, rather than this:

$('el').addClass();

I'd rather it be:

phi('el').addClass();

This will prevent confusion.

On https://github.com/cerebralideas/phi-dom-library/blob/master/phidom.js#L41 I can't tell exactly what you're doing with the global.$ and doing a $.noConflict. I'm guessing it is some kind of check for the existence of jQuery? If there is, are you utilizing that instead? Can you explain?

I do like the idea of using jQuery if it happens to be loaded onto the page. Angular uses a similar convention. If no jQuery is on the page, then it uses its jQLite; if it is on the page, then it uses the real jQuery lib.

NateJackman commented 11 years ago

It is checking if $ is used, and if so, returning it to what has defined it to prevent clobbering of the same var. So if a library like jQuery has previously defined $, calling this will return that to jq and allow phi to use phidom or the phi name we set up. similar to using jQuery vs $.

I hadn't thought about using jQuery if it is available, but that would make sense. I think this would be worth looking into.

cerebrl commented 11 years ago

Ah, that makes sense. Thanks for explaining.

Yeah, I got the idea for Angular; thought it was cool :)