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

Props JamesDiGioia.
Fixes #35630.

git-svn-id: https://develop.svn.wordpress.org/trunk@36637 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Pascal Birchler 2016-02-23 17:15:23 +00:00
parent 203966bd4f
commit fe824ee872

View File

@ -26,7 +26,6 @@
share_dialog_close = document.querySelector( '.wp-embed-share-dialog-close' ), share_dialog_close = document.querySelector( '.wp-embed-share-dialog-close' ),
share_input = document.querySelectorAll( '.wp-embed-share-input' ), share_input = document.querySelectorAll( '.wp-embed-share-input' ),
share_dialog_tabs = document.querySelectorAll( '.wp-embed-share-tab-button button' ), share_dialog_tabs = document.querySelectorAll( '.wp-embed-share-tab-button button' ),
links = document.getElementsByTagName( 'a' ),
i; i;
if ( share_input ) { if ( share_input ) {
@ -154,13 +153,13 @@
/** /**
* Send link target to the parent (embedding) site. * Send link target to the parent (embedding) site.
*/ */
sendEmbedMessage( 'link', href ); if ( href ) {
e.preventDefault(); sendEmbedMessage( 'link', href );
e.preventDefault();
}
} }
for ( i = 0; i < links.length; i++ ) { document.addEventListener( 'click', linkClickHandler );
links[ i ].addEventListener( 'click', linkClickHandler );
}
} }
/** /**