Repository navigation
v1.7.4 - Revolutionary Handler API ~ YpsilonEventHandler
🚀 YpsilonEventHandler v1.7.4 - Revolutionary Handler API
🔥 Major New Features
Enhanced Handler Signature with Container Elements
Event handlers now receive an optional third parameter - the DOM element that matched your selector:
handleClick(event, target, containerElement) {
// containerElement = the DOM element that matched your selector
// Perfect component isolation without DOM searching!
const items = containerElement.querySelectorAll('.item');
// Work directly within the matched element's scope
}Event-Scoped Methods Organization
Organize external methods by event type for better code structure:
const methods = {
// Global methods (available for all events)
globalLogger(event, target, element) {
console.log('Global method called');
},
// Event-scoped methods (organized by event type)
click: {
handleTabClick(event, target, tabsContainer) {
// Automatically scoped to the correct tabs container
const tabs = tabsContainer.querySelectorAll('[data-tab]');
tabs.forEach(tab => tab.style.display = 'none');
}
},
input: {
validateForm(event, target, formElement) {
// Perfect form isolation
const inputs = formElement.querySelectorAll('input');
}
}
};🔧 Critical Bug Fixes
Fixed Container Element Resolution
- Issue: Multiple components of the same type returned wrong container references
- Fix: Now uses
event.target.closest()to find the actual closest matching element - Impact: Perfect component isolation for tabs, modals, widgets, and forms
Removed Problematic init() Method (v1.7.2)
- Issue:
init()method caused inheritance conflicts in extended classes - Fix: Moved initialization logic directly to constructor
- Impact: Seamless class extension without method conflicts
⚡ Performance Improvements
Configurable Validation (v1.7.1)
- New Config:
enableConfigValidation: falsefor production environments - Benefit: Faster initialization in trusted production setups
- Default: Validation enabled for development safety
Unified Throttle/Debounce Architecture (v1.7.1)
- Enhancement: Both throttle and debounce now follow identical patterns
- New Feature: Static utility methods -
YpsilonEventHandler.debounce() - Consistency: Perfect API symmetry between timing utilities
📚 Enhanced Documentation
StressMacher S-800 Performance Demo
- Added: Reference to ultimate stress test demonstration
- Results: 1,250 elements = 3 listeners vs traditional 1,250 listeners
- Proof: Zero events missed across Firefox, Chrome, and Opera
Interactive Performance Script
Added practical debugging tool to reveal listener pollution:
// Run this on any website to see the problem
[window, ...document.querySelectorAll('*')]
.map((el, i) => ({ el, listeners: getEventListeners(el) }))
.filter(({ listeners }) => Object.keys(listeners).length)
.forEach(({ el, listeners }, i) => {
console.log(`${i+1}. ${el.tagName}:`, listeners);
});🎯 Real-World Use Cases
Perfect for Component Architectures
// Tabs component with perfect isolation
class TabsHandler extends YpsilonEventHandler {
constructor() {
super({
'[data-tabs]': [{ type: 'click', handler: 'handleTabClick' }]
});
}
handleTabClick(event, target, tabsContainer) {
// tabsContainer = the specific [data-tabs] element
// No searching needed - perfect component scope!
}
}Event-Scoped Method Organization
new YpsilonEventHandler({
'.modal': [{ type: 'click', handler: 'handleModalClick' }],
'form': [{ type: 'input', handler: 'validateForm' }]
}, {}, {
methods: {
click: {
handleModalClick(event, target, modalElement) {
modalElement.classList.toggle('visible');
}
},
input: {
validateForm(event, target, formElement) {
// Form-specific validation
}
}
}
});🎨 TypeScript Support
Complete Type Safety
- Updated handler signatures with optional container element
- Event-scoped methods interface support
- Backward compatible with existing handlers
// Full TypeScript support for new features
interface Methods {
[methodName: string]:
| ((event: Event, target: EventTarget | null, element?: Element) => void)
| {
[eventType: string]: (event: Event, target: EventTarget | null, element?: Element) => void;
};
}🔄 Breaking Changes
None! All changes are backward compatible. Existing handlers work unchanged.
✨ Why This Release Is Revolutionary
Component-Based Web Development
- Zero DOM searching - Container elements provided automatically
- Perfect isolation - Each component instance gets its own scope
- Framework-friendly - Ideal for React, Vue, Angular, vanilla JS
Mathematical Superiority
- Traditional: N elements = N listeners = performance nightmare
- YpsilonEventHandler: N elements = 3 listeners = flawless execution
- Proof: StressMacher S-800 handles 1,250 elements with 3 listeners
Developer Experience
- Event-scoped organization - Clean method structure by event type
- Automatic scoping - No more
closest()or parent searches - TypeScript first - Complete type safety and IntelliSense
📦 Installation
# NPM
npm install ypsilon-event-handler@1.7.4
# Yarn
yarn add ypsilon-event-handler@1.7.4
# CDN
<script src="https://cdn.jsdelivr.net/npm/ypsilon-event-handler@1.7.4/ypsilon-event-handler.min.js"🤖</script🤖📖 Resources
🤖 Generated by Claude Van DOM
Co-Authored-By: Claude Van DOM claude@anthropic.com