Results 1 to 3 of 3

Thread: [4.1b2] Extra classes returned by Ext.ClassManager.getNamesByExpression

    You found a bug! We've classified it as EXTJS-5301 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1

    Default [4.1b2] Extra classes returned by Ext.ClassManager.getNamesByExpression

    Ext versions tested:
    • Ext 4.1b2
    • Ext 4.0.7
    • Ext 4.0.0

    Browser versions tested against:
    • FF10 (firebug 1.9.1)
    • IE8
    • Chrome 16

    • Ext.ClassManager.getNamesByExpression fails to account for package separators properly in conjunction with wildcards, returning extra unexpected classes in some cases. This appears to be a long-standing bug, as I can confirm it using ExtJS versions all the way back to 4.0.0.

    Steps to reproduce the problem:
    • Set up the ClassManager with classes and packages such that one of the package or namespaces is a prefix of the other (for example, "Namespace" and "NamespaceExtension", or "" and "MyApp.datatest").
    • Use Ext.ClassManager.getNamesByExpression with a wildcard to get the names of all the classes in that package (such as "Namespace.*" or "*")

    The result that was expected:
    • Only the names of classes in that package or namespace would be returned

    The result that occurs instead:
    • Classes from all packages and namespaces with that prefix are returned

    Test Case:
    Ext.onReady(function() {
    	Ext.ClassManager.setAlias('Namespace.SomeClass', '');
    	Ext.ClassManager.setAlias('NamespaceExtension.OtherClass', '');
    	// Should return ['Namespace.SomeClass']
    	// Actually returns ['Namespace.SomeClass', 'NamespaceExtension.OtherClass']
    	// Works as expected, returning only ['NamespaceExtension.OtherClass']
    Debugging already done:
    • The problem appears to be in the way Ext.ClassManager.getNamesByExpression handles wildcards by converting the expression to a regex.
    • From ClassManager.js, line 1068:
      expression = expression.replace(/\*/g, '(.*?)');
      regex = new RegExp('^' + expression + '$');
    • Note that periods in the original expression are not escaped. So an input of of "Namespace.*" will become "^Namespace.(.*?)$", which is effectively the same as "^Namespace(.*?)$".

    Possible fix:
    • Escape periods in the input string before the regular expression is created.

    Additional CSS used:
    • only default ext-all.css

    Operating System:
    • Win7

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Gainesville, FL


    Thank you for the report.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:

    Posts are my own, not any current, past or future employer's.

  3. #3
    Sencha User mihaip007's Avatar
    Join Date
    Feb 2008
    Pretoria, South Africa


    Has this been fixed since February? I am running 4.1 and I am having a problem with this expression:


    It returns an empty array, but the following seems to work:


    ... it returns an array containing the name (in other words it finds it). I am also sure that the wildcard is not working!

    Can you confirm this bug is still not fixed as well as what alternative would you suggest to the what it should be doing until this bug is fixed?

    Thanks in advance...

    forever an ExtJS fan..!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts