Skip to content

Commit

Permalink
update jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Sep 21, 2020
1 parent d18640d commit 0592fea
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions packages/block-library/src/embed/wp-embed-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ class WpEmbedPreview extends Component {

/**
* Checks for WordPress embed event signaling the height
* change when content loads.
* change when iframe content loads or iframe's window is resized.
* The event is send from WordPress core with window.postMessage function.
*
* References:
* window.postMessage: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
* WordPress core embed-template on load: https://github.com/WordPress/WordPress/blob/master/wp-includes/js/wp-embed-template.js#L143
* WordPress core embed-template on resize: https://github.com/WordPress/WordPress/blob/master/wp-includes/js/wp-embed-template.js#L187
*
* @param {WPSyntheticEvent} event Message event.
*/
Expand All @@ -42,14 +48,13 @@ class WpEmbedPreview extends Component {
return;
}

const iframes = document.querySelectorAll(
`iframe[data-secret="${ secret }"`
);
( iframes || [] ).forEach( ( iframe ) => {
if ( +iframe.height !== value ) {
iframe.height = value;
}
} );
document
.querySelectorAll( `iframe[data-secret="${ secret }"` )
.forEach( ( iframe ) => {
if ( +iframe.height !== value ) {
iframe.height = value;
}
} );
}

/**
Expand Down

0 comments on commit 0592fea

Please sign in to comment.