Tapestry 5
  1. Tapestry 5
  2. TAP5-1775

Improve javascript performance while creating zone events

    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") {

      1. changes.patch
        2 kB
        Pedro Ayala

        Activity

        Pedro Ayala created issue -
        Pedro Ayala made changes -
        Field Original Value New Value
        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.
        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") {
         
        Pedro Ayala made changes -
        Attachment changes.patch [ 12506467 ]
        Pedro Ayala made changes -
        Attachment changes.patch [ 12506467 ]
        Pedro Ayala made changes -
        Attachment changes.patch [ 12506471 ]
        Howard M. Lewis Ship made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Fix Version/s 5.4 [ 12316401 ]
        Resolution Invalid [ 6 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Pedro Ayala
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development