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:
parent
203966bd4f
commit
fe824ee872
@ -26,7 +26,6 @@
|
||||
share_dialog_close = document.querySelector( '.wp-embed-share-dialog-close' ),
|
||||
share_input = document.querySelectorAll( '.wp-embed-share-input' ),
|
||||
share_dialog_tabs = document.querySelectorAll( '.wp-embed-share-tab-button button' ),
|
||||
links = document.getElementsByTagName( 'a' ),
|
||||
i;
|
||||
|
||||
if ( share_input ) {
|
||||
@ -154,13 +153,13 @@
|
||||
/**
|
||||
* Send link target to the parent (embedding) site.
|
||||
*/
|
||||
sendEmbedMessage( 'link', href );
|
||||
e.preventDefault();
|
||||
if ( href ) {
|
||||
sendEmbedMessage( 'link', href );
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
for ( i = 0; i < links.length; i++ ) {
|
||||
links[ i ].addEventListener( 'click', linkClickHandler );
|
||||
}
|
||||
document.addEventListener( 'click', linkClickHandler );
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user