/
stream_actions.js
45 lines (36 loc) · 1.01 KB
/
stream_actions.js
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { session } from "../"
import morph from "./actions/morph"
export const StreamActions = {
after() {
this.targetElements.forEach((e) => e.parentElement?.insertBefore(this.templateContent, e.nextSibling))
},
append() {
this.removeDuplicateTargetChildren()
this.targetElements.forEach((e) => e.append(this.templateContent))
},
before() {
this.targetElements.forEach((e) => e.parentElement?.insertBefore(this.templateContent, e))
},
prepend() {
this.removeDuplicateTargetChildren()
this.targetElements.forEach((e) => e.prepend(this.templateContent))
},
remove() {
this.targetElements.forEach((e) => e.remove())
},
replace() {
this.targetElements.forEach((e) => e.replaceWith(this.templateContent))
},
update() {
this.targetElements.forEach((targetElement) => {
targetElement.innerHTML = ""
targetElement.append(this.templateContent)
})
},
refresh() {
session.refresh(this.baseURI, this.requestId)
},
morph() {
morph(this)
}
}