4 ms·
I like, but I'm curious why this is a jQuery plugin.
by prezjordan 14y ago
I like, but I'm curious why this is a jQuery plugin.
- tcas 14y agoLooking 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.
- ville 14y agoI think a good alternative would be just to accept a number. url(1) instead of url('1')
- davecardwell 14y agojQuery simply does this: isNumeric: function( obj ) { return !isNaN( parseFloat(obj) ) && isFinite( obj ); }
- csarva 14y agoNo 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..
- bmuon 14y agoModules are the way to go, not polluting an arbitrary namespace.
- mmcnickle 14y agoI 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');
- rane 14y agoI don't see what DOM has to do with URL parsing.