Commit a41a46d
Improve suggestor.js with security, accessibility and code quality enhancements (#2964)
* Improve suggestor.js with security, accessibility and code quality enhancements
- Security: Replace .html() with .text() to prevent XSS vulnerabilities
- Accessibility: Add ARIA attributes (role, aria-selected, aria-expanded, aria-haspopup)
- Code organization: Extract duplicate CSS logic into applyListItemStyle helper function
- Code readability: Add KEY_CODES constants and isInputKey helper function
- Error handling: Improve AJAX error handling with console logging
- Code cleanup: Remove commented-out code
- Documentation: Add JSDoc comments for all major functions
- Modern practices: Use "use strict" mode and consistent naming
- Performance: Use outerHeight/outerWidth for better calculations
- Return value: Add 'return this' for jQuery chaining support
* Fix code quality issues in suggestor.js based on code review
- Fix isInputKey range check: Split NUM_0-Z range into separate NUM_0-NUM_9 and A-Z ranges
to exclude non-input keycodes (58-64: :;<=>?@) between them
- Optimize duplicate checking: Replace O(n²) nested loop with O(n) Set-based lookup
using object as hash map for better performance
- Extract magic number: Replace hardcoded 6 with VERTICAL_SPACING constant for
better maintainability and discoverability
---------
Co-authored-by: Claude <[email protected]>1 parent 425836f commit a41a46d
1 file changed
+235
-175
lines changed
0 commit comments