WordPress.org

Make WordPress Core

Changeset 40064


Ignore:
Timestamp:
02/16/17 21:20:45 (4 months ago)
Author:
westonruter
Message:

Customize: Skip intercepting non-HTTP(S) links in customizer preview just as jump links are ignored.

Ensures that links with javascript:, mailto: and other protocols work as expected in the customizer preview.

Fixes #39797.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/customize-preview.js

    r39584 r40064  
    146146            } 
    147147 
     148            // Allow internal jump links and JS links to behave normally without preventing default. 
    148149            isInternalJumpLink = ( '#' === link.attr( 'href' ).substr( 0, 1 ) ); 
    149  
    150             // Allow internal jump links to behave normally without preventing default. 
    151             if ( isInternalJumpLink ) { 
     150            if ( isInternalJumpLink || ! /^https?:$/.test( link.prop( 'protocol' ) ) ) { 
    152151                return; 
    153152            } 
     
    335334        } 
    336335 
    337         // Ignore links with href="#" or href="#id". 
    338         if ( '#' === $( element ).attr( 'href' ).substr( 0, 1 ) ) { 
     336        // Ignore links with href="#", href="#id", or non-HTTP protocols (e.g. javascript: and mailto:). 
     337        if ( '#' === $( element ).attr( 'href' ).substr( 0, 1 ) || ! /^https?:$/.test( element.protocol ) ) { 
    339338            return; 
    340339        } 
Note: See TracChangeset for help on using the changeset viewer.