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

Expose DOM Helpers #2754

Closed
wants to merge 11 commits into from
Closed

Conversation

misteroneill
Copy link
Member

Building on the ModalDialog work...

  • Adds a couple small DOM convenience methods - $ and $$ (essentially, querySelector and querySelectorAll respectively).
  • Adds a toggleElClass function.
  • Exposes a bunch of useful DOM methods on the videojs function.
  • Rewrites the className manipulation functions to use classList if it's available (which is true of all supported browsers except IE8).

Note: The methods are generally exposed without the El part (i.e. Dom.hasElClass is exposed as videojs.hasClass). The reason for this is parity with popular JS libraries (jQuery, etc) that people are familiar with.

@@ -44,6 +44,8 @@ let trackToJson_ = function(track) {
* @function textTracksToJson
*/
let textTracksToJson = function(tech) {

// Cannot use $$ here because it is not an instance of Tech
let trackEls = tech.el().querySelectorAll('track');
Copy link
Member

Choose a reason for hiding this comment

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

isn't tech here a Tech and thus it should have $$?

Copy link
Member Author

Choose a reason for hiding this comment

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

It wasn't when I was working on this PR (hence the comment).

I think it makes sense to use more powerful native APIs when they are
available. In this case, we use `classList` for all browsers but IE8 and
IE9.

Also, adds slightly more rigorous tests for these functions.
- Also adds comprehensive tests.
- Exposes the function as `toggleClass` on `videojs`.
- Adds the `toggleClass` method to components.
@gkatsev
Copy link
Member

gkatsev commented Nov 9, 2015

LGTM. Going to make another PR after this to fix the tracks JSON that I commented about above.

@gkatsev gkatsev closed this in f2fa8f8 Nov 9, 2015
@misteroneill misteroneill deleted the expose-dom-helpers branch November 9, 2015 22:59
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