Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions src/ustream-embedapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ var UstreamEmbed = (function () {
function createInstance (iframe) {
var element = getIframe(iframe),
instance = (function (element) {

// check and see if the element is there before continuing
if(!element) {
return;
}

var isReady = false,
instanceObj,
embedHost,
Expand Down Expand Up @@ -242,14 +248,19 @@ var UstreamEmbed = (function () {
}
};
}(element));

if (!element.id) {

// make sure the element is there before we ask for the ID
if (element && !element.id) {
element.id = "UstreamEmbed" + Math.ceil(Math.random() * 100000);
}

// again, let's make sure the element is there before setting the instance id
if (element) {
instance.id = element.id;

instance.id = element.id;

instances[element.id] = instance;
instances[element.id] = instance;
}

return instance;
}

Expand Down