Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8917859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:35:51+00:00 2026-06-15T05:35:51+00:00

This is a small jQuery plugin I use for getting console.warn when there is

  • 0

This is a small jQuery plugin I use for getting console.warn when there is no selector returned from a query

(function($, w, c){
if(!w.jQuery || !c) return;
c.w = c.warn || c.log; // safely use either warn or log
// jQuery and console.warn/log are available, we're good to go

var _find = $.find,
    _attr = $.fn.attr;

// 'duck punch' jQuery.find - Replace with a wrapper function with our warning which returns the original result
$.find = function(){
    var result = _find.apply(this, arguments);
    if(!result.length) c.w('jQuery Selector "' + result.selector + '" returned no matches');
    return result;
};

$.fn.attr = function(attr){
    if(arguments.length === 1) {
        var result = _attr.call(this, attr);
        if(result === void 0) {
            c.w('jQuery Attribute Getter for "' + attr + '" returned undefined for selector "' + $(this).selector + '"');
        }
        return result;
    } else {
        _attr.apply(this, arguments);
        return this;
    }
};

w.jQuery = w.$;

}(jQuery, window, console));

And what I get in the console when there is an empty selector is this:

Uncaught TypeError: Object function (){
    var result = _find.apply(this, arguments);
    if(!result.length) c.w('jQuery Selector "' + result.selector + '" returned no matches');
    return result;
} has no method 'matchesSelector'

I don’t understand what is matchesSelector and where it comes from

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:35:52+00:00Added an answer on June 15, 2026 at 5:35 am

    You are overwriting $.find but not replacing the properties jQuery is relying on. $.find has many properties, such as matchesSelector, matches etc which are lost because they have not been assigned to your function.

    You should not overwrite $.find

    You can attach them back but I have a bad feeling some other problems are still missed:

    var _find = $.find,
        empty = function() {};
    
    $.find = function() {};
    
    for (var key in _find) {
                                          //ignore standard function properties
        if (_find.hasOwnProperty(key) && !empty.hasOwnProperty(key)) {
            $.find[key] = _find[key];
        }
    }
    

    There are hardcoded references to $.find properties all over jQuery source, such as this one:

     jQuery.find.matchesSelector(cur, selectors) ) {
    

    Result of filling a normal object with those:

    var myObj = {}, empty = function(){};
    
    for (var key in $.find) {
        if ($.find.hasOwnProperty(key) && !empty.hasOwnProperty(key)) {
            myObj[key] = $.find[key];
        }
    }
    
    myObj
    Object
    attr: function (a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}}
    contains: function (a,b){return a!==b&&(a.contains?a.contains(b):!0)}
    error: function (a){throw new Error("Syntax error, unrecognized expression: "+a)}
    filter: function (a,c,d,e){var f,g,h,i,j,k,l,n,p,q=a,r=[],s=c,t=c&&c[0]&&m.isXML(c[0]);while(a&&c.length){for(h in o.filter)if((f=o.leftMatch[h].exec(a))!=null&&f[2]){k=o.filter[h],l=f[1],g=!1,f.splice(1,1);if(l.substr(l.length-1)==="\\")continue;s===r&&(r=[]);if(o.preFilter[h]){f=o.preFilter[h](f,s,d,r,e,t);if(!f)g=i=!0;else if(f===!0)continue}if(f)for(n=0;(j=s[n])!=null;n++)j&&(i=k(j,f,n,s),p=e^i,d&&i!=null?p?g=!0:s[n]=!1:p&&(r.push(j),g=!0));if(i!==b){d||(s=r),a=a.replace(o.match[h],"");if(!g)return[];break}}if(a===q)if(g==null)m.error(a);else break;q=a}return s}
    find: function (a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e<f;e++){h=o.order[e];if(g=o.leftMatch[h].exec(a)){i=g[1],g.splice(1,1);if(i.substr(i.length-1)!=="\\"){g[1]=(g[1]||"").replace(j,""),d=o.find[h](g,b,c);if(d!=null){a=a.replace(o.match[h],"");break}}}}d||(d=typeof b.getElementsByTagName!="undefined"?b.getElementsByTagName("*"):[]);return{set:d,expr:a}}
    getText: function (a){var b,c,d=a.nodeType,e="";if(d){if(d===1||d===9){if(typeof a.textContent=="string")return a.textContent;if(typeof a.innerText=="string")return a.innerText.replace(k,"");for(a=a.firstChild;a;a=a.nextSibling)e+=n(a)}else if(d===3||d===4)return a.nodeValue}else for(b=0;c=a[b];b++)c.nodeType!==8&&(e+=n(c));return e}
    isXML: function (a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1}
    matches: function (a,b){return m(a,null,null,b)}
    matchesSelector: function (a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}
    selectors: Object
    uniqueSort: function (a){if(u){h=i,a.sort(u);if(h)for(var b=1;b<a.length;b++)a[b]===a[b-1]&&a.splice(b--,1)}return a}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Take a look at this snazy plugin: http://remysharp.com/2007/12/28/jquery-tag-suggestion/ ** it's real small Source: http://remysharp.com/downloads/tag.js
I'm working on a small app that makes use of the jQuery plugin Fullcalendar.
I have written a small jQuery plugin with the following structure: (function($) { //
I'm doing jquery small animation of fade in to form validation This is working
Ok I am having a small issue I am trying to turn this jQuery
I set a height with jquery. After this height is set, another function shall
We use this small utility method. But we don't like it. Since it's not
There's a very simple jquery plugin: autotextarea. I'd like to teach it one little
So, I'm using the XSLT plugin for JQuery, and here's my code: function AddPlotcardEventHandlers(){
I am working on a small jQuery plugin that autoscrolls through a set of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.