Skip to content

Feature: Support colon character in event namespaces #3983

@SuperPat45

Description

@SuperPat45

Description

I have an issue for unbind an event created for a component having a colon character in its id.
The colon character is used as separator by the JSF API.

The event is bind like this:

var elementId = document.getElementById('test:colon').id.replace(':', '\\:'),
selector = '#' + elementId + ' .clickMe';
$(document).on('click.xxx-' + elementId, selector, function (){alert('clicked');});

But the off function does not unbing the event:
$(document).off('click.xxx-' + elementId, selector);

The issue appear in the off function on the line:
( !tmp || tmp.test( handleObj.namespace ) )
The regex pattern failed to test the expression because of the escape character...
If you change the line:
tmp = tmp[ 2 ] && new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
by escaping the \ character:
tmp = tmp[ 2 ] && new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ).replace('\\', '\\\\') + "(\\.|$)" );
seem to works in the chrome debugger:
debug

  • What do you expect to happen?
    Event must be unbind
  • What actually happens?
    Event is not unbind
  • Which browsers are affected?
    All browsers

Link to test case

https://jsbin.com/yamitatece/edit?html,js,output

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions