New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of jQuery dependency, use Riot object as a namespace #63

Closed
wants to merge 7 commits into
from

Conversation

Projects
None yet
7 participants
@alisnic

alisnic commented Jan 10, 2014

I think that it's within the Riot's spirit to make no assumption about what DOM manipulation library one should choose. Riot should be simple and welcoming to any choice.

However, to implement that, we need a namespace in which Riot will live, therefore global.Riot. This will also allow to add extensions easier, since you won't have to pollute the DOM library with foreign code. Everything that belongs to Riot should be in Riot namespace, simple as that.

This will also prevent a lot of raised eyebrows when newcomers will see $.route (jquery route? what?)

Whether you accept this change or not, it's up to you.

PS: I've removed some random empty lines for consistency.

@tipiirai

This comment has been minimized.

Show comment
Hide comment
@tipiirai

tipiirai Jan 10, 2014

Member

I've thought about the same but this is somewhat big decision. Not going to merge now since I have to think about this.

Member

tipiirai commented Jan 10, 2014

I've thought about the same but this is somewhat big decision. Not going to merge now since I have to think about this.

@alisnic

This comment has been minimized.

Show comment
Hide comment
@alisnic

alisnic Jan 10, 2014

Pros

  • decoupled from jQuery (the coupling wasn't necessary at all, Riot does not use anything from jQuery, except its namespace)
  • a namespace for future improvements/extensions
  • Unambiguous api (no $.route, $.delegate)

Cons

  • ??? (I can't think of any)

alisnic commented Jan 10, 2014

Pros

  • decoupled from jQuery (the coupling wasn't necessary at all, Riot does not use anything from jQuery, except its namespace)
  • a namespace for future improvements/extensions
  • Unambiguous api (no $.route, $.delegate)

Cons

  • ??? (I can't think of any)
@daytonn

This comment has been minimized.

Show comment
Hide comment
@daytonn

daytonn Jan 11, 2014

I second this. It's a bit of cheating to say it's a 1kb framework when it depends on jQuery. It goes against the whole vanilla javascript argument. Riot is just vanilla icing on the jQuery cake with this dependency in place.

Having said that, I'm a fan of this library and philosophy in general. I think this could be big... and small ;)

daytonn commented Jan 11, 2014

I second this. It's a bit of cheating to say it's a 1kb framework when it depends on jQuery. It goes against the whole vanilla javascript argument. Riot is just vanilla icing on the jQuery cake with this dependency in place.

Having said that, I'm a fan of this library and philosophy in general. I think this could be big... and small ;)

@zengabor

This comment has been minimized.

Show comment
Hide comment
@zengabor

zengabor Jan 11, 2014

I feel the same. I like Riot.js very much but I would like to see it (and use it) without jQuery.

I feel the same. I like Riot.js very much but I would like to see it (and use it) without jQuery.

@TJKoury

This comment has been minimized.

Show comment
Hide comment
@TJKoury

TJKoury Jan 12, 2014

Another agreement here. I'm thinking about using this in an end-to-end framework with ActionHero but jQuery is a dealbreaker. I want to be able to roll my own DOM manipulation library.

TJKoury commented Jan 12, 2014

Another agreement here. I'm thinking about using this in an end-to-end framework with ActionHero but jQuery is a dealbreaker. I want to be able to roll my own DOM manipulation library.

@tipiirai

This comment has been minimized.

Show comment
Hide comment
@tipiirai

tipiirai Jan 13, 2014

Member

Riot does not depend on jQuery. It just uses the $- namespace and this pull makes the library use a new riot namespace. I'm beginning to good well with that suggestion and it's likely that this will happen on v1.0.

Member

tipiirai commented Jan 13, 2014

Riot does not depend on jQuery. It just uses the $- namespace and this pull makes the library use a new riot namespace. I'm beginning to good well with that suggestion and it's likely that this will happen on v1.0.

@guscost

This comment has been minimized.

Show comment
Hide comment
@guscost

guscost Jan 13, 2014

+1 for the riot namespace. I'm looking into using this with jQuery, but there are people who are going to want to use this framework with other DOM libraries or querySelector/vanilla stuff and they might be confused by the $. Avoiding that is probably worth the extra bit of pollution.

guscost commented Jan 13, 2014

+1 for the riot namespace. I'm looking into using this with jQuery, but there are people who are going to want to use this framework with other DOM libraries or querySelector/vanilla stuff and they might be confused by the $. Avoiding that is probably worth the extra bit of pollution.

@daytonn

This comment has been minimized.

Show comment
Hide comment
@daytonn

daytonn Jan 13, 2014

@tipiirai, It may not use any jQuery directly but it most certainly depends on it. If I can't run the code without including jQuery (or at least stubbing jQuery), that's a dependency.

daytonn commented Jan 13, 2014

@tipiirai, It may not use any jQuery directly but it most certainly depends on it. If I can't run the code without including jQuery (or at least stubbing jQuery), that's a dependency.

@fernandoacorreia

This comment has been minimized.

Show comment
Hide comment
@fernandoacorreia

fernandoacorreia Jan 13, 2014

Contributor

I second the proposal of adopting the riot namespace instead of $. If for nothing else, it will avoid getting people confused into thinking there's some relation between Riot.js and jQuery.

Contributor

fernandoacorreia commented Jan 13, 2014

I second the proposal of adopting the riot namespace instead of $. If for nothing else, it will avoid getting people confused into thinking there's some relation between Riot.js and jQuery.

@TJKoury

This comment has been minimized.

Show comment
Hide comment
@TJKoury

TJKoury Jan 14, 2014

Definitely use the riot namespace.
On Jan 13, 2014 6:59 PM, "Fernando Correia" notifications@github.com
wrote:

I second the proposal of adopting the riot namespace instead of $. If for
nothing else, it will avoid getting people confused into thinking there's
some relation between Riot.js and jQuery.


Reply to this email directly or view it on GitHubhttps://github.com/moot/riotjs/pull/63#issuecomment-32225860
.

TJKoury commented Jan 14, 2014

Definitely use the riot namespace.
On Jan 13, 2014 6:59 PM, "Fernando Correia" notifications@github.com
wrote:

I second the proposal of adopting the riot namespace instead of $. If for
nothing else, it will avoid getting people confused into thinking there's
some relation between Riot.js and jQuery.


Reply to this email directly or view it on GitHubhttps://github.com/moot/riotjs/pull/63#issuecomment-32225860
.

@tipiirai

This comment has been minimized.

Show comment
Hide comment
@tipiirai

tipiirai Jan 14, 2014

Member

@daytonn the $- namespace is dynamically created if it's not present, see:

https://github.com/moot/riotjs/blob/master/riot.js#L102

So Riot can be used without jQuery / Zepto. But anyway – enough +1 votes here so I'll use the riot namespace on v1.0.

Member

tipiirai commented Jan 14, 2014

@daytonn the $- namespace is dynamically created if it's not present, see:

https://github.com/moot/riotjs/blob/master/riot.js#L102

So Riot can be used without jQuery / Zepto. But anyway – enough +1 votes here so I'll use the riot namespace on v1.0.

@daytonn

This comment has been minimized.

Show comment
Hide comment
@daytonn

daytonn Jan 14, 2014

@tipiirai, didn't catch that. I do prefer the Riot namespace. Cute short namespaces like $ and _ are losing their appeal in my book.

daytonn commented Jan 14, 2014

@tipiirai, didn't catch that. I do prefer the Riot namespace. Cute short namespaces like $ and _ are losing their appeal in my book.

@tipiirai

This comment has been minimized.

Show comment
Hide comment
@tipiirai

tipiirai Jan 14, 2014

Member

Haha. Good to hear. Do you mind explaining why you don't like short namespaces? Just curious. Thanks.

Member

tipiirai commented Jan 14, 2014

Haha. Good to hear. Do you mind explaining why you don't like short namespaces? Just curious. Thanks.

@daytonn

This comment has been minimized.

Show comment
Hide comment
@daytonn

daytonn Jan 14, 2014

@tipiirai $ is here to stay but it's becoming impossible to really know what it is. Is it jQuery, Zepto or some other DOM selection library. Currently in Riot it could also be just an object. What do we buy with the ambiguity? My editor can enter any number of characters with a simple command so I can't say that I'm saving a whole lot of typing. Ever look at code with a lot of underscore? It becomes ridiculous looking _(_(foo).map(function(prop) { return prop.subprop; })).first() (contrived example but you get the point). When using a proper namespace, it's perfectly clear what I'm accessing. If I really needed a shorter namespace I could simply var $ = Riot; and call it a day. It's not necessarily that I don't like short namespaces. I'm just not sure why every library needs to be a one character swiss-army function. The shortest namespace of all is to extend built-in prototypes. But since the community at large has deemed that evil we have these obtuse one-character namespace/functions. I'm becoming less convinced that it's desirable. I think Riot is short enough, no?

daytonn commented Jan 14, 2014

@tipiirai $ is here to stay but it's becoming impossible to really know what it is. Is it jQuery, Zepto or some other DOM selection library. Currently in Riot it could also be just an object. What do we buy with the ambiguity? My editor can enter any number of characters with a simple command so I can't say that I'm saving a whole lot of typing. Ever look at code with a lot of underscore? It becomes ridiculous looking _(_(foo).map(function(prop) { return prop.subprop; })).first() (contrived example but you get the point). When using a proper namespace, it's perfectly clear what I'm accessing. If I really needed a shorter namespace I could simply var $ = Riot; and call it a day. It's not necessarily that I don't like short namespaces. I'm just not sure why every library needs to be a one character swiss-army function. The shortest namespace of all is to extend built-in prototypes. But since the community at large has deemed that evil we have these obtuse one-character namespace/functions. I'm becoming less convinced that it's desirable. I think Riot is short enough, no?

@tipiirai

This comment has been minimized.

Show comment
Hide comment
@tipiirai

tipiirai Jan 14, 2014

Member

@daytonn Thank you for the good explanation. Easy to agree with. riot is definitely short enough. I just wanted a more elaborate explanation from you. Thanks.

Member

tipiirai commented Jan 14, 2014

@daytonn Thank you for the good explanation. Easy to agree with. riot is definitely short enough. I just wanted a more elaborate explanation from you. Thanks.

@alisnic

This comment has been minimized.

Show comment
Hide comment
@alisnic

alisnic Apr 16, 2014

No need for this PR anymore

alisnic commented Apr 16, 2014

No need for this PR anymore

@alisnic alisnic closed this Apr 16, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment