Skip to content

Commit d47e298

Browse files
authored
Added the possibility to set an id to the iframe
For some reason, I need to have an id on the created iframe. Thus this PR.
1 parent 5720e2a commit d47e298

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,14 @@ const connectCallReceiver = (info, methods, destructionPromise) => {
322322
* the iframe.
323323
* @param {Object} options
324324
* @param {string} options.url The URL of the webpage that should be loaded into the created iframe.
325+
* @param {string} options.id The id that should be set to the created iframe.
325326
* @param {HTMLElement} [options.appendTo] The container to which the iframe should be appended.
326327
* @param {Object} [options.methods={}] Methods that may be called by the iframe.
327328
* @param {Number} [options.timeout] The amount of time, in milliseconds, Penpal should wait
328329
* for the child to respond before rejecting the connection promise.
329330
* @return {Child}
330331
*/
331-
Penpal.connectToChild = ({ url, appendTo, methods = {}, timeout }) => {
332+
Penpal.connectToChild = ({ url, id = null, appendTo, methods = {}, timeout }) => {
332333
let destroy;
333334
const connectionDestructionPromise = new DestructionPromise(
334335
resolveConnectionDestructionPromise => {
@@ -338,6 +339,7 @@ Penpal.connectToChild = ({ url, appendTo, methods = {}, timeout }) => {
338339

339340
const parent = window;
340341
const iframe = document.createElement('iframe');
342+
iframe.id = id;
341343

342344
(appendTo || document.body).appendChild(iframe);
343345

0 commit comments

Comments
 (0)