blob: 9278435004ad318c653f18243f665108e6e2988d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
import { register } from '../utils/adopter.js'
import Element from './Element.js'
export default class Container extends Element {
flatten (parent = this, index) {
this.each(function () {
if (this instanceof Container) {
return this.flatten().ungroup()
}
})
return this
}
ungroup (parent = this.parent(), index = parent.index(this)) {
// when parent != this, we want append all elements to the end
index = index === -1 ? parent.children().length : index
this.each(function (i, children) {
// reverse each
return children[children.length - i - 1].toParent(parent, index)
})
return this.remove()
}
}
register(Container, 'Container')
|