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

Add <style> to player tag instead of head #3240

Closed

Conversation

andyearnshaw
Copy link
Contributor

Description

Another portability fix (see #3230). Currently, players moved to or created in a different window from the video.js script will not have the proper dimensions applied.

Specific Changes proposed

The video dimensions stylesheet is added to the player element instead of <head>. The scoped attribute is also set, though only supported by Firefox it also serves as a cosmetic validation for where the element is contained (scoped style elements are permitted alongside flow content).

By doing this, the element can be moved to another window or frame without losing these dimensions. All browsers support <style> elements outside of <head>, though it is technically invalid without the scoped attribute. Behaviour-wise, nothing has changed so current tests continue to pass and additional unit tests are unnecessary.

Requirements Checklist

  • Feature implemented / Bug fixed
  • Reviewed by Two Core Contributors

@gkatsev
Copy link
Member

gkatsev commented Apr 5, 2016

Thank you for the PR; unfortunately, we cannot accept it.

We used to have this in the player but we got rid of it. The reason why we cannot have it be inside the player element is that then it's really hard to override the player css.
So, if you wanted to size the player with just .video-js selector without the use of !important, you cannot do it because the player dimensions element has at least the same specificity but most definitely will come after your own css in the CSSOM.
Also, the scoped attribute apparently is probably not ever going to be standardized, unfortunately.

However, one thing you should take a look at -- which will be released as 5.9.0 later today -- is the VIDEOJS_NO_DYNAMIC_STYLE property. This actually makes videojs not add any of these dynamic styles to the DOM at all and should help you make the player portable.

Thanks, hope to see more from you!

@gkatsev gkatsev closed this Apr 5, 2016
@andyearnshaw andyearnshaw deleted the feature/portable-style branch April 6, 2016 11:53
@andyearnshaw
Copy link
Contributor Author

Ah indeed, I can understand the specificity problem. I think scoped is probably going to be dropped from the spec too, as Firefox is the only browser to implement it and Blink have performance/optimisation concerns. In the distant future this would probably be better handled using a shadow tree anyway.

Thanks for pointing me towards VIDEOJS_NO_DYNAMIC_STYLE 😄.

@gkatsev
Copy link
Member

gkatsev commented Apr 6, 2016

No problem, it just got added and released as part of 5.9.

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

Successfully merging this pull request may close these issues.

2 participants