Skip to main content

Search and Top Navigation

#9384 closed bug (fixed)

Opened June 19, 2013 10:36PM UTC

Closed June 21, 2013 12:40AM UTC

Last modified November 26, 2013 04:13PM UTC

Menu: _focus function forgets null check with doing a pattern match on event.type

Reported by: darkdev Owned by:
Priority: minor Milestone: 1.10.4
Component: ui.menu Version: 1.10.3
Keywords: Cc:
Blocked by: Blocking:
Description

Sorry to report as a bug instead of just fixing myself, but i have to run and wouldn't want to modify without running all the unit tests.

ISSUE: ui.menu widget's focus function forgets null check with doing a pattern match on event.type. The UI Menu API documentation even gives the menu("focus",...) example passing null as the event argument. And focus gets triggered from a variety of other cases, which means that due to this other events aren't able to be called as suggested in the API docs.

Browser: Chrome

Noticed in ui 1.10.2 (line 11774), found to still be present in 1.10.3 (line 11790)

problematic code:

if ( nested.length && ( /^mouse/.test( event.type ) ) ) {

this._startOpening(nested);

}

correction suggestion:

if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {

this._startOpening(nested);

}

I have already found a work around, which is to always pass the supposedly optional event argument. But it's not ideal. here is my working code, without eventObj argument it fails, i am just prototyping for now, but i will be using this with non-mouse events to position a menu where the mouse is.

var menuHolder = $(menuHTML).appendTo($("body")).menu(menuOptions);

menuHolder.menu("next", eventObj);

menuHolder.menu("expand", eventObj);

//bind the events for disposing of the context menu

$("body").find("*").not($("button#testContextMenu, .ContextMenuHolder, .ContextMenuHolder *")).mousedown(closeContextMenu);

Attachments (0)
Change History (4)

Changed June 21, 2013 12:40AM UTC by TJ VanToll comment:1

resolution: → fixed
status: newclosed

Menu: Ensure an event was passed before checking its type. Fixes #9384 - Menu: _focus function forgets null check with doing a pattern match on event.type

Changeset: 670f650b99103bcea779f8ad0428e05cb7e37053

Changed June 21, 2013 12:41AM UTC by tj.vantoll comment:2

milestone: none1.11.0

Changed November 26, 2013 04:12PM UTC by TJ VanToll comment:3

Menu: Ensure an event was passed before checking its type. Fixes #9384 - Menu: _focus function forgets null check with doing a pattern match on event.type

(cherry picked from commit 670f650b99103bcea779f8ad0428e05cb7e37053)

Changeset: 9b398520c5e1a313d0c1ebfa7dfd892f8b3e440c

Changed November 26, 2013 04:13PM UTC by scottgonzalez comment:4

milestone: 1.11.01.10.4