Tapestry
  1. Tapestry
  2. TAPESTRY-2541

Tapestry DOM needs basic methods to manipulate the DOM post-render

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.13
    • Fix Version/s: 5.0.15
    • Component/s: tapestry-core
    • Labels:
      None

      Description

      It would be useful if I want to write a component that needs to manipulate its body... A trivial example would be a "stripwhitespace" component :

      <t:stripwhitespace>

      My string with too

      many white spaces

      </ t:stripwhitespace>

      In that case I would like to access the <t:body /> string to remove some spaces...

        Activity

        Hide
        Martin Papy added a comment -

        HLS said this :

        Tapestry renders content as a lightweight DOM, not a character stream (as Tapestry 4 did). The approach I'd take is two fold: I would start a new element inside beginRender() and store the Element object inside a component field. Inside afterRender(), I would visit the context of the element, looking for Text nodes that I could change.

        What's missing is that the API for Element, Text and Node allows for additions to a Node (this is how Tapestry adds <link> elements for CSS and <script> elements for JavaScript to a rendered page), but there's very little support for otherwise modifying the DOM structure. New API to remove, replace and reparent DOM nodes would help with what you're trying to accomplish. Again, more API is needed, but that kind of change is driven by an actual need, either by the framework, or by people creating JIRA issues.

        Show
        Martin Papy added a comment - HLS said this : Tapestry renders content as a lightweight DOM, not a character stream (as Tapestry 4 did). The approach I'd take is two fold: I would start a new element inside beginRender() and store the Element object inside a component field. Inside afterRender(), I would visit the context of the element, looking for Text nodes that I could change. What's missing is that the API for Element, Text and Node allows for additions to a Node (this is how Tapestry adds <link> elements for CSS and <script> elements for JavaScript to a rendered page), but there's very little support for otherwise modifying the DOM structure. New API to remove, replace and reparent DOM nodes would help with what you're trying to accomplish. Again, more API is needed, but that kind of change is driven by an actual need, either by the framework, or by people creating JIRA issues.
        Hide
        Howard M. Lewis Ship added a comment -

        Ability to query nodes, change and coelesce text nodes, re-parent elements, etc.

        Please confirm this is what you specifically need.

        Show
        Howard M. Lewis Ship added a comment - Ability to query nodes, change and coelesce text nodes, re-parent elements, etc. Please confirm this is what you specifically need.
        Hide
        Martin Papy added a comment -

        Yes this is what I need, I think this could be very usefull.

        Show
        Martin Papy added a comment - Yes this is what I need, I think this could be very usefull.

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            Martin Papy
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development