* Add new component children * @param {Component|String} components Component to add * @param {Object} [opts={}] Options for the append action * @return {Array} Array of appended components * @example * someComponent.get('components').length // -> 0 * const videoComponent = someCo
(components: ComponentAdd, opts: AddOptions = {})
| 1129 | * someComponent.append(otherComponent, { at: 0 }); |
| 1130 | */ |
| 1131 | append<T extends Component = Component>(components: ComponentAdd, opts: AddOptions = {}): T[] { |
| 1132 | const compArr = isArray(components) ? [...components] : [components]; |
| 1133 | const toAppend = compArr.map((comp) => { |
| 1134 | if (isString(comp)) { |
| 1135 | return comp; |
| 1136 | } else { |
| 1137 | // I have to remove components from the old container before adding them to a new one |
| 1138 | comp.collection && (comp as Component).collection.remove(comp, { temporary: true } as any); |
| 1139 | return comp; |
| 1140 | } |
| 1141 | }); |
| 1142 | const result = this.components().add(toAppend, { |
| 1143 | action: ActionLabelComponents.add, |
| 1144 | ...opts, |
| 1145 | }); |
| 1146 | return result as T[]; |
| 1147 | } |
| 1148 | |
| 1149 | /** |
| 1150 | * Set new collection if `components` are provided, otherwise the |
no test coverage detected