Tapestry 5
  1. Tapestry 5
  2. TAP5-804

Element#addClassName can create an additional new 'class' attribute

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.18
    • Fix Version/s: 5.2.2
    • Component/s: tapestry-core
    • Labels:
      None

      Description

      When writing a mixin that uses Element#addClassName, I noticed that I was getting two 'class' attributes in my element - rather than the one I was expecting.

      I've narrowed the problem down to a problem with how namespaces are used in Element and the following test case shows the problem. The "actual" output is:

      <e class="a b" class="a" xmlns="http://www.w3.org/1999/xhtml"></e>

      --------------------------------------

      package test.com.db.fusion.iface.web.tapestry5.mixins;

      import junit.framework.TestCase;

      import org.apache.tapestry5.dom.DefaultMarkupModel;
      import org.apache.tapestry5.dom.Document;
      import org.apache.tapestry5.dom.Element;

      public class AddClassNameTest extends TestCase {

      public void test()

      { Document document = new Document(new DefaultMarkupModel()); Element element = document.newRootElement("http://www.w3.org/1999/xhtml", "e"); element.attribute("class", "a"); element.addClassName("b"); assertEquals("<e class=\"a b\" xmlns=\"http://www.w3.org/1999/xhtml\"></e>", element.toString()); }

      }

        Issue Links

          Activity

          Hide
          Hudson added a comment -

          Integrated in tapestry-5.2-freestyle #212 (See https://hudson.apache.org/hudson/job/tapestry-5.2-freestyle/212/)

          Show
          Hudson added a comment - Integrated in tapestry-5.2-freestyle #212 (See https://hudson.apache.org/hudson/job/tapestry-5.2-freestyle/212/ )
          Josh Canfield made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 5.2.2 [ 12315376 ]
          Resolution Fixed [ 1 ]
          Josh Canfield made changes -
          Assignee Josh Canfield [ joshcanfield ]
          Paul Field made changes -
          Field Original Value New Value
          Link This issue relates to TAP5-708 [ TAP5-708 ]
          Hide
          Josh Canfield added a comment -

          This is related to TAP5-708

          Element.addClassName uses Element.forceAttributes which uses the elements namespace to search for the attributes, which have a null namespace.

          I'm submitting a patch for TAP5-708 which resolves this.

          Show
          Josh Canfield added a comment - This is related to TAP5-708 Element.addClassName uses Element.forceAttributes which uses the elements namespace to search for the attributes, which have a null namespace. I'm submitting a patch for TAP5-708 which resolves this.
          Paul Field created issue -

            People

            • Assignee:
              Josh Canfield
              Reporter:
              Paul Field
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development