Make WordPress Core

Changeset 23389


Ignore:
Timestamp:
02/06/2013 07:10:04 AM (14 years ago)
Author:
azaozz
Message:

Heartbeat API: fix error in IE < 9, props SergeyBiryukov, don't attempt to bind events to cross-domain iframes, see #23216

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/js/heartbeat.js

    r23382 r23389  
    3232                if ( typeof( window.heartbeatSettings != 'undefined' ) ) {
    3333                        settings = $.extend( {}, window.heartbeatSettings );
    34                         delete window.heartbeatSettings;
     34                        window.heartbeatSettings = null;
    3535
    3636                        // Add private vars
     
    6262
    6363                        return (new Date()).getTime();
     64                }
     65
     66                function isLocalFrame(frame) {
     67                        try {
     68                                if ( frame.contentWindow.document )
     69                                        return true;
     70                        } catch(e) {}
     71
     72                        return false;
    6473                }
    6574
     
    188197                function setFrameEvents() {
    189198                        $('iframe').each( function(i, frame){
     199                                if ( !isLocalFrame(frame) )
     200                                        return;
     201
    190202                                if ( $.data(frame, 'wp-heartbeat-focus') )
    191203                                        return;
     
    207219                }).on('focus.wp-heartbeat-focus', function(){
    208220                        $('iframe').each( function(i, frame){
     221                                if ( !isLocalFrame(frame) )
     222                                        return;
     223
    209224                                $.removeData(frame, 'wp-heartbeat-focus');
    210225                                $(frame.contentWindow).off('.wp-heartbeat-focus');
     
    218233                        $(document).off('.wp-heartbeat-active');
    219234                        $('iframe').each( function(i, frame){
     235                                if ( !isLocalFrame(frame) )
     236                                        return;
     237
    220238                                $(frame.contentWindow).off('.wp-heartbeat-active');
    221239                        });
     
    244262                                $(document).on('mouseover.wp-heartbeat-active keyup.wp-heartbeat-active', function(){ userIsActive(); });
    245263                                $('iframe').each( function(i, frame){
     264                                        if ( !isLocalFrame(frame) )
     265                                                return;
     266
    246267                                        $(frame.contentWindow).on('mouseover.wp-heartbeat-active keyup.wp-heartbeat-active', function(){ userIsActive(); });
    247268                                });
Note: See TracChangeset for help on using the changeset viewer.