Skip to content

Commit

Permalink
Expose some dom.js methods. Fixes #2683
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicky Gerritsen committed Oct 20, 2015
1 parent 40b6ad3 commit cfe5212
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
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');
});

0 comments on commit cfe5212

Please sign in to comment.