blob: ebaba503526ae838f45950036940e8e791f6be27 (
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
29
30
|
import { register } from '../utils/adopter.js'
import Element from './Element.js'
export default class Container extends Element {
flatten (parent) {
this.each(function () {
if (this instanceof Container) return this.flatten(parent).ungroup(parent)
return this.toParent(parent)
})
// we need this so that the root does not get removed
this.node.firstElementChild || this.remove()
return this
}
ungroup (parent) {
parent = parent || this.parent()
this.each(function () {
return this.toParent(parent)
})
this.remove()
return this
}
}
register(Container, 'Container')
|