Core(Events): remove m_ prefix & convert into ES6 syntax and improve typing - #34940
Conversation
90bdc62 to
8e84993
Compare
There was a problem hiding this comment.
Pull request overview
Refactors DevExtreme’s internal events infrastructure by migrating the emitter and pointer-strategy hierarchies from Class.inherit() to native ES6 classes, while tightening TypeScript typings across the events pipeline and removing several @ts-expect-error workarounds.
Changes:
- Converted core event emitters (click/hold/drag/swipe/transform/gesture*), pointer strategies, and related helpers to ES6 classes with explicit TS types.
- Improved type declarations (
eventDelta,dxElementWrapper.is) to match runtime behavior and eliminate downstream TS suppressions. - Updated tests and internal integration points (e.g.,
ComponentWrapper, QUnit emitter subclass) to work with native class constructors/statics.
Reviewed changes
Copilot reviewed 22 out of 24 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/devextreme/testing/tests/DevExpress.ui.events/eventsInteraction.tests.js | Updates test-only emitter subclassing to use constructor/super with native classes. |
| packages/devextreme/js/core/renderer.d.ts | Widens dxElementWrapper.is() to accept Element (aligns with runtime behavior). |
| packages/devextreme/js/common/core/events/utils/index.d.ts | Fixes eventDelta(from, to) signature to accept {x,y,time} objects (aligns with runtime usage). |
| packages/devextreme/js/__internal/ui/text_box/text_editor.base.ts | Removes a now-unneeded TS suppression due to widened is() typing. |
| packages/devextreme/js/__internal/events/pointer/m_touch.ts | Migrates touch pointer strategy to ES6 class and adds stronger typing for normalization. |
| packages/devextreme/js/__internal/events/pointer/m_observer.ts | Converts pointer observer from function-constructor to class, adds typed event map and methods. |
| packages/devextreme/js/__internal/events/pointer/m_mouse.ts | Migrates mouse pointer strategy to ES6 class and types observer usage. |
| packages/devextreme/js/__internal/events/pointer/m_mouse_and_touch.ts | Migrates combined strategy to ES6 class and modernizes state handling. |
| packages/devextreme/js/__internal/events/pointer/m_base.ts | Converts base pointer strategy to ES6 class and introduces typed event/init shapes. |
| packages/devextreme/js/__internal/events/m_transform.ts | Converts transform emitter to ES6 class and introduces typed vector math structures. |
| packages/devextreme/js/__internal/events/m_swipe.ts | Converts swipe emitter to ES6 class and introduces typed strategies/event data. |
| packages/devextreme/js/__internal/events/m_hover.ts | Replaces Class.inherit hover events with ES6 classes and typed handler storage. |
| packages/devextreme/js/__internal/events/m_hold.ts | Converts hold emitter to ES6 class and removes incorrect eventDelta suppression via fixed typings. |
| packages/devextreme/js/__internal/events/m_drag.ts | Converts drag emitter to ES6 class and adds explicit types for drop target registration/config. |
| packages/devextreme/js/__internal/events/m_dblclick.ts | Converts dblclick implementation to ES6 class with explicit event typing. |
| packages/devextreme/js/__internal/events/m_contextmenu.ts | Converts context menu event implementation to ES6 class with typed handlers. |
| packages/devextreme/js/__internal/events/m_click.ts | Converts click emitter to ES6 class; tightens typing around node-disposing subscriptions (keeps known latent bug suppressed as documented). |
| packages/devextreme/js/__internal/events/gesture/m_emitter.gesture.ts | Converts gesture emitter to ES6 class, adds explicit gesture event/direction types, and moves statics into class body. |
| packages/devextreme/js/__internal/events/gesture/m_emitter.gesture.scroll.ts | Converts scroll emitter + locker hierarchy to ES6 classes and introduces typed locker/config/event shapes. |
| packages/devextreme/js/__internal/events/core/m_keyboard_processor.ts | Converts keyboard processor to ES6 class, adds options interface, and exposes statics. |
| packages/devextreme/js/__internal/events/core/m_emitter.ts | Converts base Emitter to ES6 class and defines core event/config typing used throughout the pipeline. |
| packages/devextreme/js/__internal/events/core/m_emitter.feedback.ts | Converts feedback emitter and helper to ES6 classes; moves lock to a static class method. |
| packages/devextreme/js/__internal/events/core/m_emitter_registrator.ts | Converts event manager/registrator to ES6 class with improved typing for emitter registration and event flow. |
| packages/devextreme/js/__internal/core/r1/component_wrapper.ts | Removes any cast by using the new typed KeyboardProcessor.createKeyDownOptions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
8e84993 to
47c87de
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 66 out of 69 changed files in this pull request and generated no new comments.
Suppressed comments (2)
packages/devextreme/js/__internal/events/pointer/mouse_and_touch.ts:92
- MouseAndTouchStrategy.dispose() calls super.dispose() without forwarding the element argument. For noBubble pointer events (dxpointerenter/dxpointerleave), BaseStrategy.dispose() needs the element to unsubscribe; missing it can leave handlers attached or call eventsEngine.off with an undefined target.
super.dispose();
this._skipNextEvents = false;
this._mouseLocked = false;
clearTimeout(this._unlockMouseTimer);
}
packages/devextreme/js/__internal/events/core/keyboard_processor.ts:34
- createKeyDownOptions assigns normalizeKeyName(e) (typed as string | undefined in events/utils) to KeyboardKeyDownEvent.keyName (typed as string) and suppresses it with @ts-expect-error. Prefer providing a fallback string here so the runtime value matches the declared type and the suppression can be removed.
47c87de to
a3659e9
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 66 out of 69 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
packages/devextreme/js/__internal/events/click.ts:52
subscribeNodesDisposing()returns{ onceCallback, nodes }, but the code destructures{ nodes, callback }(and even suppresses it with@ts-expect-error). At runtimecallbackisundefined, sounsubscribeNodesDisposing()won’t remove the specific handler and may detach unintended listeners depending on howeventsEngine.off()treats an undefined callback.
a3659e9 to
e3b1dbc
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 66 out of 69 changed files in this pull request and generated no new comments.
Suppressed comments (1)
packages/devextreme/js/__internal/events/click.ts:52
- The unsubscribe path uses
callback, butsubscribeNodesDisposing()returns{ onceCallback, nodes }(seejs/__internal/events/utils/m_event_nodes_disposing.ts). As written,callbackis alwaysundefined, sounsubscribeNodesDisposing()will remove alldxremovehandlers from the nodes (or fail to remove the intended one), which is a functional bug and can break other subscriptions.
e3b1dbc to
a731e5c
Compare
a731e5c to
e766a32
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 66 out of 69 changed files in this pull request and generated no new comments.
Suppressed comments (1)
packages/devextreme/js/__internal/events/click.ts:54
- The nodes-disposing subscription returned by subscribeNodesDisposing() contains
onceCallback, but this code destructurescallback(which is always undefined). That makes unsubscribeNodesDisposing() call off() with an undefined handler, which can remove all dxremove handlers from the nodes and break cleanup for subsequent clicks.
No description provided.