WordPress.org

Make WordPress Core

Changeset 36637


Ignore:
Timestamp:
02/23/16 17:15:23 (17 months ago)
Author:
swissspidy
Message:

Embeds: Make the click event handler work for dynamically added links.

Props JamesDiGioia.
Fixes #35630.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/wp-embed-template.js

    r35577 r36637  
    2727            share_input = document.querySelectorAll( '.wp-embed-share-input' ), 
    2828            share_dialog_tabs = document.querySelectorAll( '.wp-embed-share-tab-button button' ), 
    29             links = document.getElementsByTagName( 'a' ), 
    3029            i; 
    3130 
     
    155154             * Send link target to the parent (embedding) site. 
    156155             */ 
    157             sendEmbedMessage( 'link', href ); 
    158             e.preventDefault(); 
    159         } 
    160  
    161         for ( i = 0; i < links.length; i++ ) { 
    162             links[ i ].addEventListener( 'click', linkClickHandler ); 
    163         } 
     156            if ( href ) { 
     157                sendEmbedMessage( 'link', href ); 
     158                e.preventDefault(); 
     159            } 
     160        } 
     161 
     162        document.addEventListener( 'click', linkClickHandler ); 
    164163    } 
    165164 
Note: See TracChangeset for help on using the changeset viewer.