Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/core/action_descriptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export const defaultActionDescriptorFilters: ActionDescriptorFilters = {
},
}

export const nativeActionDescriptors: string[] = ["capture", "once", "passive", "!passive"]

export interface ActionDescriptor {
eventTarget: EventTarget
eventOptions: AddEventListenerOptions
Expand Down
6 changes: 4 additions & 2 deletions src/core/dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Application } from "./application"
import { Binding } from "./binding"
import { BindingObserverDelegate } from "./binding_observer"
import { EventListener } from "./event_listener"
import { nativeActionDescriptors } from "./action_descriptor"

export class Dispatcher implements BindingObserverDelegate {
readonly application: Application
Expand Down Expand Up @@ -112,8 +113,9 @@ export class Dispatcher implements BindingObserverDelegate {

private cacheKey(eventName: string, eventOptions: any): string {
const parts = [eventName]
Object.keys(eventOptions)
.sort()

nativeActionDescriptors
.filter((key) => key in eventOptions)
.forEach((key) => {
parts.push(`${eventOptions[key] ? "" : "!"}${key}`)
})
Expand Down
12 changes: 12 additions & 0 deletions src/tests/modules/core/action_ordering_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ export default class ActionOrderingTests extends LogControllerTestCase {
)
}

async "test adding an action to the left with a :stop modifier"() {
this.actionValue = "c#log3:stop c#log d#log2"
await this.nextFrame
await this.triggerEvent(this.buttonElement, "click")

this.assertActions(
{ name: "log3", identifier: "c", eventType: "click", currentTarget: this.buttonElement },
{ name: "log", identifier: "c", eventType: "click", currentTarget: this.buttonElement },
{ name: "log2", identifier: "d", eventType: "click", currentTarget: this.buttonElement }
)
}

async "test removing an action from the right"() {
this.actionValue = "c#log d#log2"
await this.nextFrame
Expand Down