rails/jquery-rails

jQuery 1.12.0 - Uncaught TypeError: Cannot read property 'opener' of null

josefsj3m opened this issue · 6 comments

jQuery 1.12.0 is throwing exception in line 6705 ( Sources tab) in Chrome 47.0.2526.106 (64-bit) and Firefox 43.0.4. The exception occurs in the following code:

        // Support: IE<=11+, Firefox<=30+ (#15098, #14150)
        // IE throws on elements created in popups
        // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
        var view = elem.ownerDocument.defaultView;

        if ( !view.opener ) {     <=== This line is throwing the exception
            view = window;
        }

I downgraded to jquery-rails v 4.0.5 and everything works ok.

This look like a jquery issue, not jquery-rails.

Looks like it is a jquery-migrate issue jquery/jquery-migrate#127

I do not believe this is a jquery-migrate issue. I have filed a bug against jquery core that explains more, but I think this issue should be left open until resolved: jquery/jquery#2852.

TLDR I think rails ujs might have some problems with jquery 2.2.0

(That said the version number of jquery in the title of this issue is off, but the problem is virtually the same)

Furthermore, this is pretty easy to repro against jquery-rails 4.1.0:

  1. Get vanilla app with jquery 2.2.0 and UJS going.

  2. Add the following link to any view:

    <a href="/blah" data-method="post" rel="nofollow">bangarang</a>
  3. load the page, click the link

  4. exception will be thrown

Disregard, I am a moron, was actually jq-migrate all along.