Comparar commits
1 Commits
master
...
no-conflict
| Autor | SHA1 | Data | |
|---|---|---|---|
| c40ea4186b |
@@ -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
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário