Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options in data-setup attribute are ignored when the initialization is called before autoSetup #1514

Closed
wants to merge 3 commits into from

Conversation

chikathreesix
Copy link
Contributor

Because only vjs.autoSetup picks the option from data-setup, this attribute will be ignored if the initialization is called before that. Sometimes I face this issue and options in data-setup are ignored, so I made Player.getTagSetting pick the option from data-setup as well.

@heff
Copy link
Member

heff commented Sep 17, 2014

Interesting, thanks! I don't think we've run into this before because most people either use autoSetup by itself,

<video data-setup="[options]"></video>

or they don't use the data-setup attribute and pass in the options in the init function

<video> </video>
videojs(id, options)

But I could see there potentially being a situation where you have two async scripts, the autoSetup scripts and another script that references the player, and that would cause this issue. Is that the situation you have?

};

tagOptions = vjs.getElementAttributes(tag);
dataSetup = tagOptions['data-setup'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're doing this here now we should also remove it from the autoSetup script. And move the code comments over from there over to this one. Just the "If empty string, make it a parsable json object" one.

options = vjs.JSON.parse(options || '{}');

@chikathreesix
Copy link
Contributor Author

Thank you for your quick response! Yes, that's what exactly my situation is. Because a few of my scripts refer the Player instance, not sure who to be the first. Therefore I am having the option in data-setup.
By the way, I've fixed my code according to your comments.

@mmcc
Copy link
Member

mmcc commented Sep 18, 2014

Thanks! This looks good to me, so we should pull this into the next release.

@chikathreesix
Copy link
Contributor Author

Thanks!

@heff
Copy link
Member

heff commented Sep 29, 2014

Good to go for this week's release.

@heff heff closed this in f47bf26 Sep 29, 2014
@heff
Copy link
Member

heff commented Sep 29, 2014

Merged in. Thank you!

@chikathreesix
Copy link
Contributor Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants