Error in console every time – bug

New home Forums Pro Add-on Error in console every time – bug

Tagged: ,

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #32006

    I’ve posted this one before but it is still a problem for me. There is a Javascript error in the Chrome Dev’ Tools console each time I open our Gmaps page:

    Uncaught TypeError: Cannot read property 'defaultView' of undefined
        at new _.Hw (
        at Object.Dz.f (
        at Object._.Q (
        at new zg (
        at MYMAP.(anonymous function).init (

    During my investigations it appears to be caused by this line in core.js: = new google.maps.Map(jQuery(selector)[0],myOptions);

    Google Maps can’t take a jQuery selector as a parameter, so perhaps changing that line might be the solution?

    This bug has been haunting me for months – the ticket I raised previously is nowhere to be found, so it would be nice to squash this once and for all.


    I tried to patch core.js but that didn’t work. I changed the code to pass a DOM element instead of a jQuery element but it was no good.. the error still occurs. I’m stumped.


    Hi Anthony

    I hope this finds you well, thanks for reporting this

    Could you please turn off the optimization plugin you’re running so I can look at this properly?

    jQuery selectors return an array of elements, so jQuery(selector)[0] would give you the DOM element (as opposed to a jQuery object)

    If I could get a look at the un-minified code I can shed some light on this,

    Thank you
    – Perry


    Hi Perry,

    Yes indeed, I didn’t realise that jQuery(‘selector’)[0] was a DOM element.. silly me.

    I’m afraid I can’t turn off the optimisation plugin just yet as I’ve made some changes to our Cloudflare setup and I’m waiting for that to activate.

    Incidentally if you’re debugging the code in Chrome Dev Tools you can beautify the code in the sources panel by clicking the little “{}” icon just to the left and below the horizontal scrollbar (if there is one).


    Hi Anthony

    I did try that but I’m still having trouble pinpointing this issue, I see “init” is called twice, the first time correctly, however the second time I’m not sure where it’s being called from as my call stack only shows the “init” function. Could it be that you’ve bound a listener to the window object somewhere, or called this from inline javascript?

    In any case, the problem is that the value for the first parameter “selector” is an event object, not a selector string.

    Since I can’t see the call stack, I can’t isolate this issue, that may be a side effect of the minification, so we’d have to try with that switched off. I’d be very interested to find out what’s causing this if that’s possible in the future.

    This should have any negative side effects other than displaying an error, since it’ll only halt execution in this one particular context, however you can add some code to prevent the error from appearing, just before this line = new google.maps.Map(jQuery(selector)[0],myOptions);

    Add something like this

    if(jQuery(selector).length == 0)
    console.warn(“Element not found”);

    Would that work for you?

    Kind regards
    – Perry

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.