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 some dom.js methods #2718

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
37 changes: 37 additions & 0 deletions src/js/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,43 @@ videojs.xhr = xhr;
*/
videojs.TextTrack = TextTrack;

/**
* Creates an element and applies properties.
*
* @param {String=} tagName Name of tag to be created.
* @param {Object=} properties Element properties to be applied.
* @return {Element}
* @function createEl
*/
videojs.createEl = Dom.createEl;

/**
* Check if an element has a CSS class
*
* @param {Element} element Element to check
* @param {String} classToCheck Classname to check
* @function hasElClass
*/
videojs.hasElClass = Dom.hasElClass;

/**
* Add a CSS class name to an element
*
* @param {Element} element Element to add class name to
* @param {String} classToAdd Classname to add
* @function addElClass
*/
videojs.addElClass = Dom.addElClass;

/**
* Remove a CSS class name from an element
*
* @param {Element} element Element to remove from class name
* @param {String} classToRemove Classname to remove
* @function removeElClass
*/
videojs.removeElClass = Dom.removeElClass;

// REMOVING: We probably should add this to the migration plugin
// // Expose but deprecate the window[componentName] method for accessing components
// Object.getOwnPropertyNames(Component.components).forEach(function(name){
Expand Down
8 changes: 8 additions & 0 deletions test/unit/video.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import videojs from '../../src/js/video.js';
import TestHelpers from './test-helpers.js';
import Player from '../../src/js/player.js';
import * as Dom from '../../src/js/utils/dom.js';
import log from '../../src/js/utils/log.js';
import document from 'global/document';

Expand Down Expand Up @@ -78,3 +79,10 @@ test('should expose options and players properties for backward-compatibility',
ok(typeof videojs.options, 'object', 'options should be an object');
ok(typeof videojs.players, 'object', 'players should be an object');
});

test('should expose dom.js methods', function() {
ok(videojs.createEl, Dom.createEl, 'createEl should be an alias for Dom.createEl');
ok(videojs.hasElClass, Dom.hasElClass, 'hasElClass should be an alias for Dom.hasElClass');
ok(videojs.addElClass, Dom.addElClass, 'addElClass should be an alias for Dom.addElClass');
ok(videojs.removeElClass, Dom.removeElClass, 'removeElClass should be an alias for Dom.removeElClass');
});