Skip to content

rfocusMorph fails when jQuery.event.triggered is undefined #3135

@rentalhost

Description

@rentalhost

Check that first: event/trigger.js#L32

Note that it depends of jQuery.event.triggered, but not check if it contains a valid value (in some cases, it is undefined, then any concat will return something like clickundefined). Maybe the best implementation to avoid regular expression checking if something like that:

        if ( jQuery.event.triggered && rfocusMorph.test( type + jQuery.event.triggered ) ) {
            return;
        }

Another thing to consider is that this branch is less common that the next one: event/trigger.js#L36

        if ( type.indexOf( "." ) > -1 ) {

            // Namespaced trigger; create a regexp to match event type in handle()
            namespaces = type.split( "." );
            type = namespaces.shift();
            namespaces.sort();
        }

Then, in this case, we can just turn the first branch on a else if, like that:

        if ( type.indexOf( "." ) > -1 ) {

            // Namespaced trigger; create a regexp to match event type in handle()
            namespaces = type.split( "." );
            type = namespaces.shift();
            namespaces.sort();
        }
        else if ( jQuery.event.triggered && rfocusMorph.test( type + jQuery.event.triggered ) ) {
            return;
        }

Lastly, I not found any test over this branch. It continues valid/available/working on 3.0? Even if I remove this branch it continues passing on all tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions