Comparar commits

...

1 Commits

Autor SHA1 Mensagem Data
Pat O'Neill c40ea4186b feat: Add a noConflict method. 2017-10-18 12:54:35 -04:00
2 arquivos alterados com 29 adições e 0 exclusões
+17
Ver Arquivo
@@ -127,6 +127,23 @@ function videojs(id, options, ready) {
return player;
}
// Cache the previous videojs global in case it's overwritten.
const previousVideojs = window.videojs;
/**
* Removes this `videojs` global from the global namespace and returns it, so
* it can be re-used under a different name.
*
* @return {Function}
* Returns `videojs`.
*/
videojs.noConflict = function() {
if (window.videojs === videojs) {
window.videojs = previousVideojs;
}
return videojs;
};
/**
* An Object that contains lifecycle hooks as keys which point to an array
* of functions that are run when a lifecycle is triggered
+12
Ver Arquivo
@@ -3,6 +3,7 @@ import videojs from '../../src/js/video.js';
import * as Dom from '../../src/js/utils/dom.js';
import log from '../../src/js/utils/log.js';
import document from 'global/document';
import window from 'global/window';
import sinon from 'sinon';
QUnit.module('video.js', {
@@ -331,3 +332,14 @@ QUnit.test('should create a new tag for movingMediaElementInDOM', function(asser
Html5.isSupported = oldIS;
Html5.nativeSourceHandler.canPlayType = oldCPT;
});
QUnit.test('noConflict', function(assert) {
// The test build does not expose a global videojs, so we need to fake it.
window.videojs = videojs;
const vjs = videojs.noConflict();
assert.strictEqual(window.videojs, undefined);
assert.strictEqual(vjs, videojs);
});