Ticket #2246 (new New Feature)

Opened 22 months ago

Last modified 12 months ago

Create local short named aliases to global references

Reported by: fredck Owned by:
Priority: Normal Milestone: CKEditor 3.x
Component: Project : CKPackager Version:
Keywords: Confirmed Cc:

Description

The packager should be able to scan a function for all global references made inside of it. A global reference is a name not declared inside the function scope with the "var" or "function" statements.

For example, suppose we have the following function:

function( param )
{
    if ( CKEDITOR.env.IE || CKEDITOR.tools.trim( param ) == '' )
        CKEDITOR.doStuff();

    CKEDITOR.doOtherStuff();

    if ( CKEDITOR.env.IE )
        alert( CKEDITOR );
   
    return CKEDITOR.tools.trim( CKEDITOR.doAgain() );
}

... it would end up like this:

function( A )
{
    var B = CKEDITOR;
    var C = B.env.IE,
        D = B.tools.trim;

    if ( C || D( A ) == '' )
        B.doStuff();

    B.doOtherStuff();

    if ( C )
        alert( B );
   
    return D( B.doAgain() );
}

Note that the code is smart enough to reuse the new names when creating other var names too.

Change History

Changed 12 months ago by fredck

  • milestone changed from CKEditor 3.0 to CKEditor 3.x

Ok... my original example of changing CKEDITOR.tools.trim to "D" is wrong (as it looses the object scope), but the idea is still valid.

Note: See TracTickets for help on using tickets.