1
0
mirror of https://github.com/videojs/video.js.git synced 2025-07-15 01:34:23 +02:00

@misteroneill fixed internal extends usage and added a deprecation warning. closes #2390

This commit is contained in:
Pat O'Neill
2015-07-24 09:07:58 -07:00
committed by heff
parent 8be7810049
commit 456ee4e84f
5 changed files with 17 additions and 13 deletions

View File

@ -73,6 +73,7 @@ CHANGELOG
* @dmlap use seekable on source handlers when defined ([view](https://github.com/videojs/video.js/pull/2376))
* @dmlap fire seeking in the flash tech, not the SWF ([view](https://github.com/videojs/video.js/pull/2372))
* @dmlap expose the xhr helper utility ([view](https://github.com/videojs/video.js/pull/2321))
* @misteroneill fixed internal extends usage and added a deprecation warning ([view](https://github.com/videojs/video.js/pull/2390))
--------------------

View File

@ -1,11 +1,11 @@
Components
===
The Video.js player is built on top of a simple, custom UI components architecture. The player class and all control classes inherit from the Component class, or a subclass of Component.
The Video.js player is built on top of a simple, custom UI components architecture. The player class and all control classes inherit from the `Component` class, or a subclass of `Component`.
```js
videojs.Control = videojs.Component.extend();
videojs.Button = videojs.Control.extend();
videojs.PlayToggle = videojs.Button.extend();
videojs.registerComponent('Control', videojs.extends(Component));
videojs.registerComponent('Button', videojs.extends(videojs.getComponent('Control')));
videojs.registerComponent('PlayToggle', videojs.extends(videojs.getComponent('Button')));
```
The UI component architecture makes it easier to add child components to a parent component and build up an entire user interface, like the controls for the Video.js player.

View File

@ -1246,10 +1246,14 @@ class Component {
*
* @param {Object} props An object of properties
* @static
* @deprecated
* @method extend
*/
static extend(props) {
props = props || {};
log.warn('Component.extend({}) has been deprecated, use videojs.extends(Component, {}) instead');
// Set up the constructor using the supplied init method
// or using the init of the parent object
// Make sure to check the unobfuscated version for external libs
@ -1275,8 +1279,6 @@ class Component {
// Make the class extendable
subObj.extend = Component.extend;
// Make a function for creating instances
// subObj.create = CoreObject.create;
// Extend subObj's prototype with functions and other properties from props
for (let name in props) {

View File

@ -228,7 +228,7 @@ test('component can be subclassed externally', function(){
var Component = videojs.getComponent('Component');
var ControlBar = videojs.getComponent('ControlBar');
var player = new (Component.extend({
var player = new (videojs.extends(Component, {
reportUserActivity: function(){},
textTracks: function(){ return {
addEventListener: Function.prototype,

View File

@ -1,5 +1,6 @@
var noop = function() {}, clock, oldTextTracks;
import extendsFn from '../../../src/js/extends.js';
import Tech from '../../../src/js/tech/tech.js';
import { createTimeRange } from '../../../src/js/utils/time-ranges.js';
@ -103,7 +104,7 @@ test('should add the source handler interface to a tech', function(){
var sourceB = { src: 'no-support', type: 'no-support' };
// Define a new tech class
var MyTech = Tech.extend();
var MyTech = extendsFn(Tech);
// Extend Tech with source handlers
Tech.withSourceHandlers(MyTech);
@ -119,7 +120,7 @@ test('should add the source handler interface to a tech', function(){
ok(tech.setSource, 'added a setSource function to the tech instance');
// Create an internal state class for the source handler
// The internal class would be used by a source hanlder to maintain state
// The internal class would be used by a source handler to maintain state
// and provde a dispose method for the handler.
// This is optional for source handlers
var disposeCalled = false;
@ -179,7 +180,7 @@ test('should add the source handler interface to a tech', function(){
test('should handle unsupported sources with the source handler API', function(){
// Define a new tech class
var MyTech = Tech.extend();
var MyTech = extendsFn(Tech);
// Extend Tech with source handlers
Tech.withSourceHandlers(MyTech);
// Create an instance of Tech