Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-5010

Construct the "XWiki" JavaScript object using the module "loose augmentation" pattern

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Unresolved
    • Major
    • None
    • 2.2.2
    • None
    • Unknown

    Description

      See http://www.adequatelygood.com/2010/3/JavaScript-Module-Pattern-In-Depth

      Replace the whole

      if (typeof XWiki == "undefined") {
         XWiki = new Object();
      }
      
      // XWiki module augmentation
      XWiki.submodule = Class.create({
         //etc
      });
      

      by

      var XWiki = (function(x) {
      
         // module augmentation :
         x.submodule = Class.create({
           //etc.
         });
      
         return x;
      
      })(XWiki || {});
      

      which performs better and is conceptually a better construct

      Attachments

        Activity

          People

            Unassigned Unassigned
            jerome Jerome Velociter
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: