Hacker News new | past | comments | ask | show | jobs | submit login

I like, but I'm curious why this is a jQuery plugin.



Looking at the source, it looks like there's only one line that calls jQuery on line 37 (and I don't think it should be using the short calling convention without a wrapper -- if you rename jQuery to '_' or something else it won't work):

    else if($.isNumeric(arg)
There's no native JavaScript equivalent to it if I recall correctly, but there's a bunch of alternatives to it as well.

It should be easy enough to extract out the logic and repackage it. Maybe I'll fork it tomorrow and do the changes myself.


jQuery simply does this:

  isNumeric: function( obj ) {
    return !isNaN( parseFloat(obj) ) && isFinite( obj );
  }


I think a good alternative would be just to accept a number. url(1) instead of url('1')


No clue, but it's nice to have a namespace for it, rather than mucking up the global context with a simple utility method. Might be better off shimmying up to underscore (perhaps only if it's already detected, otherwise go global?), however there are lots of similar jquery 'plugins' of this nature..


Modules are the way to go, not polluting an arbitrary namespace.


I presume to allow for idiomatic use in code that already uses a lot of jQuery:

    var file = $('a#interesting').url('file')
vs

    var file = url($('a#interesting'), 'file');


I don't see what DOM has to do with URL parsing.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: