1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-04 06:48:49 +02:00

Updated component children adding to allow no name, id, or el

This commit is contained in:
Steve Heffernan 2013-01-21 17:10:54 -08:00
parent 0364e281d1
commit b6ea80b67e

View File

@ -300,21 +300,25 @@ vjs.Component.prototype.addChild = function(child, options){
component = child;
}
componentName = component.name();
componentId = component.id();
this.children_.push(component);
if (componentId) {
this.childIndex_[componentId] = component;
if (typeof component.id === 'function') {
this.childIndex_[component.id()] = component;
}
// If a name wasn't used to create the component, check if we can use the
// name function of the component
componentName = componentName || (component.name && component.name());
if (componentName) {
this.childNameIndex_[componentName] = component;
}
// Add the UI object's element to the container div (box)
this.el_.appendChild(component.el());
// Having an element is not required
if (typeof component.el === 'function' && component.el()) {
this.el_.appendChild(component.el());
}
// Return so it can stored on parent object if desired.
return component;