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

    REQUIRED INFORMATION
    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

    Description:
    • 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 "MyApp.data" 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 "MyApp.data.*")

    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:
    Code:
    Ext.onReady(function() {
    	Ext.ClassManager.setAlias('Namespace.SomeClass', '');
    	Ext.ClassManager.setAlias('NamespaceExtension.OtherClass', '');
    	
    	// Should return ['Namespace.SomeClass']
    	// Actually returns ['Namespace.SomeClass', 'NamespaceExtension.OtherClass']
    	console.log(
    		Ext.ClassManager.getNamesByExpression('Namespace.*')
    	);
    	
    	// Works as expected, returning only ['NamespaceExtension.OtherClass']
    	console.log(
    		Ext.ClassManager.getNamesByExpression('NamespaceExtension.*')
    	);
    });
    HELPFUL INFORMATION
    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:
      Code:
      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
    Location
    Gainesville, FL
    Posts
    40,448

    Default

    Thank you for the report.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

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

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

    Default

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

    Ext.ClassManager.getNamesByExpression('AppName.view.orangewiz.user.*');

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

    Ext.ClassManager.getNamesByExpression('AppName.view.orangewiz.user.transactions');

    ... 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
  •