Make WordPress Core

Changeset 40096


Ignore:
Timestamp:
02/21/2017 06:55:18 AM (8 years ago)
Author:
dd32
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.

Props westonruter.
Merges [40064] to the 4.7 branch.
Fixes #39797.

Location:
branches/4.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/src/wp-includes/js/customize-preview.js

    r39585 r40096  
    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.