mirror of
https://github.com/videojs/video.js.git
synced 2025-07-15 01:34:23 +02:00
@misteroneill rename "extends" to "extend" for ie8. closes #2624
This commit is contained in:
committed by
David LaPalomento
parent
a0b4293b82
commit
61a00db7cb
@ -138,6 +138,7 @@ CHANGELOG
|
|||||||
* @heff Fixed double loadstart and ready events ([view](https://github.com/videojs/video.js/pull/2605))
|
* @heff Fixed double loadstart and ready events ([view](https://github.com/videojs/video.js/pull/2605))
|
||||||
* @gkatsev fixed potential double default style elements ([view](https://github.com/videojs/video.js/pull/2619))
|
* @gkatsev fixed potential double default style elements ([view](https://github.com/videojs/video.js/pull/2619))
|
||||||
* @imbcmdth extended createTimeRange to support multiple timeranges ([view](https://github.com/videojs/video.js/pull/2604))
|
* @imbcmdth extended createTimeRange to support multiple timeranges ([view](https://github.com/videojs/video.js/pull/2604))
|
||||||
|
* @misteroneill rename "extends" to "extend" for ie8 ([view](https://github.com/videojs/video.js/pull/2624))
|
||||||
|
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
|
@ -1258,7 +1258,7 @@ class Component {
|
|||||||
static extend(props) {
|
static extend(props) {
|
||||||
props = props || {};
|
props = props || {};
|
||||||
|
|
||||||
log.warn('Component.extend({}) has been deprecated, use videojs.extends(Component, {}) instead');
|
log.warn('Component.extend({}) has been deprecated, use videojs.extend(Component, {}) instead');
|
||||||
|
|
||||||
// Set up the constructor using the supplied init method
|
// Set up the constructor using the supplied init method
|
||||||
// or using the init of the parent object
|
// or using the init of the parent object
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import log from './utils/log';
|
import log from './utils/log';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @file extends.js
|
* @file extend.js
|
||||||
*
|
*
|
||||||
* A combination of node inherits and babel's inherits (after transpile).
|
* A combination of node inherits and babel's inherits (after transpile).
|
||||||
* Both work the same but node adds `super_` to the subClass
|
* Both work the same but node adds `super_` to the subClass
|
||||||
@ -34,7 +34,7 @@ const _inherits = function (subClass, superClass) {
|
|||||||
* var Button = videojs.getComponent('Button');
|
* var Button = videojs.getComponent('Button');
|
||||||
* ```
|
* ```
|
||||||
* ```js
|
* ```js
|
||||||
* var MyButton = videojs.extends(Button, {
|
* var MyButton = videojs.extend(Button, {
|
||||||
* constructor: function(player, options) {
|
* constructor: function(player, options) {
|
||||||
* Button.call(this, player, options);
|
* Button.call(this, player, options);
|
||||||
* },
|
* },
|
||||||
@ -44,7 +44,7 @@ const _inherits = function (subClass, superClass) {
|
|||||||
* });
|
* });
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
const extendsFn = function(superClass, subClassMethods={}) {
|
const extendFn = function(superClass, subClassMethods={}) {
|
||||||
let subClass = function() {
|
let subClass = function() {
|
||||||
superClass.apply(this, arguments);
|
superClass.apply(this, arguments);
|
||||||
};
|
};
|
||||||
@ -75,4 +75,4 @@ const extendsFn = function(superClass, subClassMethods={}) {
|
|||||||
return subClass;
|
return subClass;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default extendsFn;
|
export default extendFn;
|
@ -19,7 +19,7 @@ import log from './utils/log.js';
|
|||||||
import * as Dom from './utils/dom.js';
|
import * as Dom from './utils/dom.js';
|
||||||
import * as browser from './utils/browser.js';
|
import * as browser from './utils/browser.js';
|
||||||
import * as Url from './utils/url.js';
|
import * as Url from './utils/url.js';
|
||||||
import extendsFn from './extends.js';
|
import extendFn from './extend.js';
|
||||||
import merge from 'lodash-compat/object/merge';
|
import merge from 'lodash-compat/object/merge';
|
||||||
import createDeprecationProxy from './utils/create-deprecation-proxy.js';
|
import createDeprecationProxy from './utils/create-deprecation-proxy.js';
|
||||||
import xhr from 'xhr';
|
import xhr from 'xhr';
|
||||||
@ -180,8 +180,8 @@ videojs.getComponent = Component.getComponent;
|
|||||||
* ```js
|
* ```js
|
||||||
* // Get a component to subclass
|
* // Get a component to subclass
|
||||||
* var VjsButton = videojs.getComponent('Button');
|
* var VjsButton = videojs.getComponent('Button');
|
||||||
* // Subclass the component (see 'extends' doc for more info)
|
* // Subclass the component (see 'extend' doc for more info)
|
||||||
* var MySpecialButton = videojs.extends(VjsButton, {});
|
* var MySpecialButton = videojs.extend(VjsButton, {});
|
||||||
* // Register the new component
|
* // Register the new component
|
||||||
* VjsButton.registerComponent('MySepcialButton', MySepcialButton);
|
* VjsButton.registerComponent('MySepcialButton', MySepcialButton);
|
||||||
* // (optionally) add the new component as a default player child
|
* // (optionally) add the new component as a default player child
|
||||||
@ -218,7 +218,7 @@ videojs.TOUCH_ENABLED = browser.TOUCH_ENABLED;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Subclass an existing class
|
* Subclass an existing class
|
||||||
* Mimics ES6 subclassing with the `extends` keyword
|
* Mimics ES6 subclassing with the `extend` keyword
|
||||||
* ```js
|
* ```js
|
||||||
* // Create a basic javascript 'class'
|
* // Create a basic javascript 'class'
|
||||||
* function MyClass(name){
|
* function MyClass(name){
|
||||||
@ -231,7 +231,7 @@ videojs.TOUCH_ENABLED = browser.TOUCH_ENABLED;
|
|||||||
* };
|
* };
|
||||||
* // Subclass the exisitng class and change the name
|
* // Subclass the exisitng class and change the name
|
||||||
* // when initializing
|
* // when initializing
|
||||||
* var MySubClass = videojs.extends(MyClass, {
|
* var MySubClass = videojs.extend(MyClass, {
|
||||||
* constructor: function(name) {
|
* constructor: function(name) {
|
||||||
* // Call the super class constructor for the subclass
|
* // Call the super class constructor for the subclass
|
||||||
* MyClass.call(this, name)
|
* MyClass.call(this, name)
|
||||||
@ -247,9 +247,9 @@ videojs.TOUCH_ENABLED = browser.TOUCH_ENABLED;
|
|||||||
* Optionally including a `constructor` function
|
* Optionally including a `constructor` function
|
||||||
* @return {Function} The newly created subclass
|
* @return {Function} The newly created subclass
|
||||||
* @mixes videojs
|
* @mixes videojs
|
||||||
* @method extends
|
* @method extend
|
||||||
*/
|
*/
|
||||||
videojs.extends = extendsFn;
|
videojs.extend = extendFn;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge two options objects recursively
|
* Merge two options objects recursively
|
||||||
|
@ -228,7 +228,7 @@ test('component can be subclassed externally', function(){
|
|||||||
var Component = videojs.getComponent('Component');
|
var Component = videojs.getComponent('Component');
|
||||||
var ControlBar = videojs.getComponent('ControlBar');
|
var ControlBar = videojs.getComponent('ControlBar');
|
||||||
|
|
||||||
var player = new (videojs.extends(Component, {
|
var player = new (videojs.extend(Component, {
|
||||||
reportUserActivity: function(){},
|
reportUserActivity: function(){},
|
||||||
textTracks: function(){ return {
|
textTracks: function(){ return {
|
||||||
addEventListener: Function.prototype,
|
addEventListener: Function.prototype,
|
||||||
@ -252,7 +252,7 @@ function testHelperMakeTag(){
|
|||||||
|
|
||||||
test('should extend Component', function(){
|
test('should extend Component', function(){
|
||||||
var Component = videojs.getComponent('Component');
|
var Component = videojs.getComponent('Component');
|
||||||
var MyComponent = videojs.extends(Component, {
|
var MyComponent = videojs.extend(Component, {
|
||||||
constructor: function() {
|
constructor: function() {
|
||||||
this.bar = true;
|
this.bar = true;
|
||||||
},
|
},
|
||||||
@ -267,7 +267,7 @@ test('should extend Component', function(){
|
|||||||
ok(myComponent.bar, 'the constructor function is used');
|
ok(myComponent.bar, 'the constructor function is used');
|
||||||
ok(myComponent.foo(), 'instance methods are applied');
|
ok(myComponent.foo(), 'instance methods are applied');
|
||||||
|
|
||||||
var NoMethods = videojs.extends(Component);
|
var NoMethods = videojs.extend(Component);
|
||||||
var noMethods = new NoMethods({});
|
var noMethods = new NoMethods({});
|
||||||
ok(noMethods.on, 'should extend component with no methods or constructor');
|
ok(noMethods.on, 'should extend component with no methods or constructor');
|
||||||
});
|
});
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import extendsFn from '../../src/js/extends.js';
|
import extendFn from '../../src/js/extend.js';
|
||||||
|
|
||||||
q.module('extends.js');
|
q.module('extend.js');
|
||||||
|
|
||||||
test('should add implicit parent constructor call', function(){
|
test('should add implicit parent constructor call', function(){
|
||||||
var superCalled = false;
|
var superCalled = false;
|
||||||
var Parent = function() {
|
var Parent = function() {
|
||||||
superCalled = true;
|
superCalled = true;
|
||||||
};
|
};
|
||||||
var Child = extendsFn(Parent, {
|
var Child = extendFn(Parent, {
|
||||||
foo: 'bar'
|
foo: 'bar'
|
||||||
});
|
});
|
||||||
var child = new Child();
|
var child = new Child();
|
@ -2,7 +2,7 @@ var noop = function() {}, clock, oldTextTracks;
|
|||||||
|
|
||||||
import Tech from '../../../src/js/tech/tech.js';
|
import Tech from '../../../src/js/tech/tech.js';
|
||||||
import { createTimeRange } from '../../../src/js/utils/time-ranges.js';
|
import { createTimeRange } from '../../../src/js/utils/time-ranges.js';
|
||||||
import extendsFn from '../../../src/js/extends.js';
|
import extendFn from '../../../src/js/extend.js';
|
||||||
import MediaError from '../../../src/js/media-error.js';
|
import MediaError from '../../../src/js/media-error.js';
|
||||||
|
|
||||||
q.module('Media Tech', {
|
q.module('Media Tech', {
|
||||||
@ -105,7 +105,7 @@ test('should add the source handler interface to a tech', function(){
|
|||||||
var sourceB = { src: 'no-support', type: 'no-support' };
|
var sourceB = { src: 'no-support', type: 'no-support' };
|
||||||
|
|
||||||
// Define a new tech class
|
// Define a new tech class
|
||||||
var MyTech = extendsFn(Tech);
|
var MyTech = extendFn(Tech);
|
||||||
|
|
||||||
// Extend Tech with source handlers
|
// Extend Tech with source handlers
|
||||||
Tech.withSourceHandlers(MyTech);
|
Tech.withSourceHandlers(MyTech);
|
||||||
@ -181,7 +181,7 @@ test('should add the source handler interface to a tech', function(){
|
|||||||
|
|
||||||
test('should handle unsupported sources with the source handler API', function(){
|
test('should handle unsupported sources with the source handler API', function(){
|
||||||
// Define a new tech class
|
// Define a new tech class
|
||||||
var MyTech = extendsFn(Tech);
|
var MyTech = extendFn(Tech);
|
||||||
// Extend Tech with source handlers
|
// Extend Tech with source handlers
|
||||||
Tech.withSourceHandlers(MyTech);
|
Tech.withSourceHandlers(MyTech);
|
||||||
// Create an instance of Tech
|
// Create an instance of Tech
|
||||||
@ -223,7 +223,7 @@ test('should track whether a video has played', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('delegates seekable to the source handler', function(){
|
test('delegates seekable to the source handler', function(){
|
||||||
let MyTech = extendsFn(Tech, {
|
let MyTech = extendFn(Tech, {
|
||||||
seekable: function() {
|
seekable: function() {
|
||||||
throw new Error('You should not be calling me!');
|
throw new Error('You should not be calling me!');
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user