Skip to content

Commit b45d3bc

Browse files
dgrahamkeithamus
andcommitted
Use generator function
Co-authored-by: Keith Cirkel <keithamus@users.noreply.github.com>
1 parent ccccb63 commit b45d3bc

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/bind.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ function handleEvent(event: Event) {
7272
}
7373

7474
type Binding = {type: string; tag: string; method: string}
75-
function bindings(el: Element): Binding[] {
76-
return (el.getAttribute('data-action') || '').split(' ').map(action => {
75+
function* bindings(el: Element): Iterable<Binding> {
76+
for (const action of (el.getAttribute('data-action') || '').split(' ')) {
7777
const eventSep = action.lastIndexOf(':')
7878
const methodSep = action.lastIndexOf('#')
7979
const type = action.slice(0, eventSep)
8080
const tag = action.slice(eventSep + 1, methodSep)
8181
const method = action.slice(methodSep + 1)
82-
return {type, tag, method}
83-
})
82+
yield {type, tag, method}
83+
}
8484
}
8585

8686
function bindActions(el: Element) {

0 commit comments

Comments
 (0)