Issue with $.selector

Issue with $.selector

Hi,

I am developing a plugin and I ran into this problem (simplified here):

  1. $.fn.test = function(fn){
        fn.apply($(this).eq(0));
    };

    $('#footer').test(function(){
        alert($(this).selector)
    });





I'm alerting $(this).selector which should say "#footer", but instead says "#footer.slice(0,1)". I get that the slice(0,1) is there because I applied fn in the context of $(this).eq(0) however, that is not a valid selector at all. Is this a glitch or expected behavior? It says in the documentation that $.selector returns the original selector, and it seems strange to me that it returns something completely invalid (as a selector) in this case. You couldn't use the string "#footer.slice(0,1)" under any circumstance as a selector which seems odd to me.

Is there a way I can apply fn in the context of the first matched element and be able to access the original selector, in this case "#footer"?

See it run here: http://terenz.io/test.html

Thanks in advance for any clarification.
JT