Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-1775

Improve javascript performance while creating zone events

    XMLWordPrintableJSON

Details

    Description

      While creating eventLinks and actionLinks it is necessary to call updateZoneOnEvent to create the observe and store the zoneId in the element for future references.
      The method is also checking if the zoneId exist before storing it in the element store information. While this feature is quite useful in debug mode, it is also consuming some time in production mode.
      With this patch we will prevent the check while running in production mode, this improve performance in older browser like internet explorer 7.

      Index: src/main/resources/org/apache/tapestry5/tapestry.js
      ===================================================================
      — src/main/resources/org/apache/tapestry5/tapestry.js
      +++ src/main/resources/org/apache/tapestry5/tapestry.js
      @@ -1020,21 +1020,32 @@ T5.extendInitializers({
      updateZoneOnEvent : function(eventName, element, zoneId, url) {
      element = $(element);

      • $T(element).zoneUpdater = true;
        -
      • var zoneElement = zoneId == '^' ? $(element).up('.t-zone')
      • : $(zoneId);
        -
      • if (!zoneElement) {
      • Tapestry
      • .error(
      • "Could not find zone element '# {zoneId}' to update on #{eventName} of element '#{elementId}'.",
        - { - zoneId : zoneId, - eventName : eventName, - elementId : element.id - });
        - return;
        + var Telement = $T(element);
        + Telement.zoneUpdater = true;
        +
        + var destZoneId = zoneId;
        + var zoneElement = null;
        + if (zoneId == '^') { + zoneElement = element.up('.t-zone'); + if (zoneElement) + destZoneId = zoneElement.id; + }
        +
        + if (Tapestry.DEBUG_ENABLED) {
        + if (!zoneElement && zoneId != '^')
        + zoneElement = $(zoneId);
        +
        + if (!zoneElement) {
        + Tapestry
        + .error(
        + "Could not find zone element '#{zoneId}

        ' to update on #

        {eventName}

        of element '#

        {elementId}

        '.",
        +

        { + zoneId : zoneId, + eventName : eventName, + elementId : element.id + }

        );
        + return;
        + }
        }

      /*
      @@ -1042,7 +1053,7 @@ T5.extendInitializers({

      • changed dynamically on the client side.
        */
      • $T(element).zoneId = zoneElement.id;
        + Telement.zoneId = zoneId;

      if (element.tagName == "FORM") {

      Attachments

        1. changes.patch
          2 kB
          Pedro Ayala

        Activity

          People

            Unassigned Unassigned
            pjayala Pedro Ayala
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: