diff --git a/src/js/video.js b/src/js/video.js index 2310dfc79c..d94747d275 100644 --- a/src/js/video.js +++ b/src/js/video.js @@ -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){ diff --git a/test/unit/video.test.js b/test/unit/video.test.js index c0994bed64..720a9e5271 100644 --- a/test/unit/video.test.js +++ b/test/unit/video.test.js @@ -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'; @@ -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'); +});