You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by "Dan Adams (JIRA)" <ji...@apache.org> on 2009/04/10 01:16:12 UTC

[jira] Created: (TAP5-640) DOM manipulation no longer allowed during rendering

DOM manipulation no longer allowed during rendering
---------------------------------------------------

                 Key: TAP5-640
                 URL: https://issues.apache.org/jira/browse/TAP5-640
             Project: Tapestry 5
          Issue Type: Bug
          Components: tapestry-core
    Affects Versions: 5.1.0.2
            Reporter: Dan Adams


We have a number of utilities that do DOM manipulation while the page is rendering. This is often a lot easier than doing it after render and results in more concise code. An example is if you have a list of elements:

<ul>
  <li>foo</li>
  <li></li>
  <li></li>
</ul>

After each LI renders, do something like this:

if (element.getChildren().isEmpty())
  element.remove();

It will work for the first empty LI and throw a NPE on the second empty LI because the container inside the element is null (which is odd since it just rendered into a container). But if you wait till after the LIs have all rendered you can loop back and do this safely. However, it's much less readable code and is a real bummer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (TAP5-640) DOM manipulation during rendering can NPE

Posted by "Howard M. Lewis Ship (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TAP5-640?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Howard M. Lewis Ship reassigned TAP5-640:
-----------------------------------------

    Assignee: Howard M. Lewis Ship

> DOM manipulation during rendering can NPE
> -----------------------------------------
>
>                 Key: TAP5-640
>                 URL: https://issues.apache.org/jira/browse/TAP5-640
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-core
>    Affects Versions: 5.1.0.2
>            Reporter: Dan Adams
>            Assignee: Howard M. Lewis Ship
>
> We have a number of utilities that do DOM manipulation while the page is rendering. This is often a lot easier than doing it after render and results in more concise code. An example is if you have a list of elements:
> <ul>
>   <li>foo</li>
>   <li></li>
>   <li></li>
> </ul>
> After each LI renders, do something like this:
> if (element.getChildren().isEmpty())
>   element.remove();
> It will work for the first empty LI and throw a NPE on the second empty LI because the container inside the element is null (which is odd since it just rendered into a container). But if you wait till after the LIs have all rendered you can loop back and do this safely. However, it's much less readable code and is a real bummer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TAP5-640) DOM manipulation during rendering can NPE

Posted by "Howard M. Lewis Ship (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TAP5-640?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12698942#action_12698942 ] 

Howard M. Lewis Ship commented on TAP5-640:
-------------------------------------------

Ok, wrote tests, found actual bug in the code that manages the linked list.

> DOM manipulation during rendering can NPE
> -----------------------------------------
>
>                 Key: TAP5-640
>                 URL: https://issues.apache.org/jira/browse/TAP5-640
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-core
>    Affects Versions: 5.1.0.2
>            Reporter: Dan Adams
>            Assignee: Howard M. Lewis Ship
>
> We have a number of utilities that do DOM manipulation while the page is rendering. This is often a lot easier than doing it after render and results in more concise code. An example is if you have a list of elements:
> <ul>
>   <li>foo</li>
>   <li></li>
>   <li></li>
> </ul>
> After each LI renders, do something like this:
> if (element.getChildren().isEmpty())
>   element.remove();
> It will work for the first empty LI and throw a NPE on the second empty LI because the container inside the element is null (which is odd since it just rendered into a container). But if you wait till after the LIs have all rendered you can loop back and do this safely. However, it's much less readable code and is a real bummer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TAP5-640) DOM manipulation during rendering can NPE

Posted by "Howard M. Lewis Ship (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TAP5-640?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12698942#action_12698942 ] 

Howard M. Lewis Ship commented on TAP5-640:
-------------------------------------------

Ok, wrote tests, found actual bug in the code that manages the linked list.

> DOM manipulation during rendering can NPE
> -----------------------------------------
>
>                 Key: TAP5-640
>                 URL: https://issues.apache.org/jira/browse/TAP5-640
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-core
>    Affects Versions: 5.1.0.2
>            Reporter: Dan Adams
>            Assignee: Howard M. Lewis Ship
>
> We have a number of utilities that do DOM manipulation while the page is rendering. This is often a lot easier than doing it after render and results in more concise code. An example is if you have a list of elements:
> <ul>
>   <li>foo</li>
>   <li></li>
>   <li></li>
> </ul>
> After each LI renders, do something like this:
> if (element.getChildren().isEmpty())
>   element.remove();
> It will work for the first empty LI and throw a NPE on the second empty LI because the container inside the element is null (which is odd since it just rendered into a container). But if you wait till after the LIs have all rendered you can loop back and do this safely. However, it's much less readable code and is a real bummer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (TAP5-640) DOM manipulation during rendering can NPE

Posted by "Howard M. Lewis Ship (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TAP5-640?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Howard M. Lewis Ship closed TAP5-640.
-------------------------------------

       Resolution: Fixed
    Fix Version/s: 5.1.0.4

> DOM manipulation during rendering can NPE
> -----------------------------------------
>
>                 Key: TAP5-640
>                 URL: https://issues.apache.org/jira/browse/TAP5-640
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-core
>    Affects Versions: 5.1.0.2
>            Reporter: Dan Adams
>            Assignee: Howard M. Lewis Ship
>             Fix For: 5.1.0.4
>
>
> We have a number of utilities that do DOM manipulation while the page is rendering. This is often a lot easier than doing it after render and results in more concise code. An example is if you have a list of elements:
> <ul>
>   <li>foo</li>
>   <li></li>
>   <li></li>
> </ul>
> After each LI renders, do something like this:
> if (element.getChildren().isEmpty())
>   element.remove();
> It will work for the first empty LI and throw a NPE on the second empty LI because the container inside the element is null (which is odd since it just rendered into a container). But if you wait till after the LIs have all rendered you can loop back and do this safely. However, it's much less readable code and is a real bummer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TAP5-640) DOM manipulation no longer allowed during rendering

Posted by "Howard M. Lewis Ship (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TAP5-640?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12697992#action_12697992 ] 

Howard M. Lewis Ship commented on TAP5-640:
-------------------------------------------

Obviously, this is related to the work to "de-collection" Element. The changes really shouldn't have been visible to the outside world. A real working test would help a lot in terms of tracking down what's happening.

> DOM manipulation no longer allowed during rendering
> ---------------------------------------------------
>
>                 Key: TAP5-640
>                 URL: https://issues.apache.org/jira/browse/TAP5-640
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-core
>    Affects Versions: 5.1.0.2
>            Reporter: Dan Adams
>
> We have a number of utilities that do DOM manipulation while the page is rendering. This is often a lot easier than doing it after render and results in more concise code. An example is if you have a list of elements:
> <ul>
>   <li>foo</li>
>   <li></li>
>   <li></li>
> </ul>
> After each LI renders, do something like this:
> if (element.getChildren().isEmpty())
>   element.remove();
> It will work for the first empty LI and throw a NPE on the second empty LI because the container inside the element is null (which is odd since it just rendered into a container). But if you wait till after the LIs have all rendered you can loop back and do this safely. However, it's much less readable code and is a real bummer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TAP5-640) DOM manipulation during rendering can NPE

Posted by "Howard M. Lewis Ship (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TAP5-640?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12698929#action_12698929 ] 

Howard M. Lewis Ship commented on TAP5-640:
-------------------------------------------

I'm about to put together a test for this; the only case I can see where this would happen is if you did element.remove() before calling writer.end().  Is that the case?  If so ... fix it!

> DOM manipulation during rendering can NPE
> -----------------------------------------
>
>                 Key: TAP5-640
>                 URL: https://issues.apache.org/jira/browse/TAP5-640
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-core
>    Affects Versions: 5.1.0.2
>            Reporter: Dan Adams
>            Assignee: Howard M. Lewis Ship
>
> We have a number of utilities that do DOM manipulation while the page is rendering. This is often a lot easier than doing it after render and results in more concise code. An example is if you have a list of elements:
> <ul>
>   <li>foo</li>
>   <li></li>
>   <li></li>
> </ul>
> After each LI renders, do something like this:
> if (element.getChildren().isEmpty())
>   element.remove();
> It will work for the first empty LI and throw a NPE on the second empty LI because the container inside the element is null (which is odd since it just rendered into a container). But if you wait till after the LIs have all rendered you can loop back and do this safely. However, it's much less readable code and is a real bummer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TAP5-640) DOM manipulation during rendering can NPE

Posted by "Howard M. Lewis Ship (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TAP5-640?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12698929#action_12698929 ] 

Howard M. Lewis Ship commented on TAP5-640:
-------------------------------------------

I'm about to put together a test for this; the only case I can see where this would happen is if you did element.remove() before calling writer.end().  Is that the case?  If so ... fix it!

> DOM manipulation during rendering can NPE
> -----------------------------------------
>
>                 Key: TAP5-640
>                 URL: https://issues.apache.org/jira/browse/TAP5-640
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-core
>    Affects Versions: 5.1.0.2
>            Reporter: Dan Adams
>            Assignee: Howard M. Lewis Ship
>
> We have a number of utilities that do DOM manipulation while the page is rendering. This is often a lot easier than doing it after render and results in more concise code. An example is if you have a list of elements:
> <ul>
>   <li>foo</li>
>   <li></li>
>   <li></li>
> </ul>
> After each LI renders, do something like this:
> if (element.getChildren().isEmpty())
>   element.remove();
> It will work for the first empty LI and throw a NPE on the second empty LI because the container inside the element is null (which is odd since it just rendered into a container). But if you wait till after the LIs have all rendered you can loop back and do this safely. However, it's much less readable code and is a real bummer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TAP5-640) DOM manipulation no longer allowed during rendering

Posted by "Howard M. Lewis Ship (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TAP5-640?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12697992#action_12697992 ] 

Howard M. Lewis Ship commented on TAP5-640:
-------------------------------------------

Obviously, this is related to the work to "de-collection" Element. The changes really shouldn't have been visible to the outside world. A real working test would help a lot in terms of tracking down what's happening.

> DOM manipulation no longer allowed during rendering
> ---------------------------------------------------
>
>                 Key: TAP5-640
>                 URL: https://issues.apache.org/jira/browse/TAP5-640
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-core
>    Affects Versions: 5.1.0.2
>            Reporter: Dan Adams
>
> We have a number of utilities that do DOM manipulation while the page is rendering. This is often a lot easier than doing it after render and results in more concise code. An example is if you have a list of elements:
> <ul>
>   <li>foo</li>
>   <li></li>
>   <li></li>
> </ul>
> After each LI renders, do something like this:
> if (element.getChildren().isEmpty())
>   element.remove();
> It will work for the first empty LI and throw a NPE on the second empty LI because the container inside the element is null (which is odd since it just rendered into a container). But if you wait till after the LIs have all rendered you can loop back and do this safely. However, it's much less readable code and is a real bummer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (TAP5-640) DOM manipulation during rendering can NPE

Posted by "Howard M. Lewis Ship (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TAP5-640?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Howard M. Lewis Ship closed TAP5-640.
-------------------------------------

       Resolution: Fixed
    Fix Version/s: 5.1.0.4

> DOM manipulation during rendering can NPE
> -----------------------------------------
>
>                 Key: TAP5-640
>                 URL: https://issues.apache.org/jira/browse/TAP5-640
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-core
>    Affects Versions: 5.1.0.2
>            Reporter: Dan Adams
>            Assignee: Howard M. Lewis Ship
>             Fix For: 5.1.0.4
>
>
> We have a number of utilities that do DOM manipulation while the page is rendering. This is often a lot easier than doing it after render and results in more concise code. An example is if you have a list of elements:
> <ul>
>   <li>foo</li>
>   <li></li>
>   <li></li>
> </ul>
> After each LI renders, do something like this:
> if (element.getChildren().isEmpty())
>   element.remove();
> It will work for the first empty LI and throw a NPE on the second empty LI because the container inside the element is null (which is odd since it just rendered into a container). But if you wait till after the LIs have all rendered you can loop back and do this safely. However, it's much less readable code and is a real bummer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (TAP5-640) DOM manipulation during rendering can NPE

Posted by "Howard M. Lewis Ship (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TAP5-640?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Howard M. Lewis Ship reassigned TAP5-640:
-----------------------------------------

    Assignee: Howard M. Lewis Ship

> DOM manipulation during rendering can NPE
> -----------------------------------------
>
>                 Key: TAP5-640
>                 URL: https://issues.apache.org/jira/browse/TAP5-640
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-core
>    Affects Versions: 5.1.0.2
>            Reporter: Dan Adams
>            Assignee: Howard M. Lewis Ship
>
> We have a number of utilities that do DOM manipulation while the page is rendering. This is often a lot easier than doing it after render and results in more concise code. An example is if you have a list of elements:
> <ul>
>   <li>foo</li>
>   <li></li>
>   <li></li>
> </ul>
> After each LI renders, do something like this:
> if (element.getChildren().isEmpty())
>   element.remove();
> It will work for the first empty LI and throw a NPE on the second empty LI because the container inside the element is null (which is odd since it just rendered into a container). But if you wait till after the LIs have all rendered you can loop back and do this safely. However, it's much less readable code and is a real bummer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (TAP5-640) DOM manipulation during rendering can NPE

Posted by "Howard M. Lewis Ship (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TAP5-640?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Howard M. Lewis Ship updated TAP5-640:
--------------------------------------

    Summary: DOM manipulation during rendering can NPE  (was: DOM manipulation no longer allowed during rendering)

> DOM manipulation during rendering can NPE
> -----------------------------------------
>
>                 Key: TAP5-640
>                 URL: https://issues.apache.org/jira/browse/TAP5-640
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-core
>    Affects Versions: 5.1.0.2
>            Reporter: Dan Adams
>
> We have a number of utilities that do DOM manipulation while the page is rendering. This is often a lot easier than doing it after render and results in more concise code. An example is if you have a list of elements:
> <ul>
>   <li>foo</li>
>   <li></li>
>   <li></li>
> </ul>
> After each LI renders, do something like this:
> if (element.getChildren().isEmpty())
>   element.remove();
> It will work for the first empty LI and throw a NPE on the second empty LI because the container inside the element is null (which is odd since it just rendered into a container). But if you wait till after the LIs have all rendered you can loop back and do this safely. However, it's much less readable code and is a real bummer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (TAP5-640) DOM manipulation during rendering can NPE

Posted by "Howard M. Lewis Ship (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/TAP5-640?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Howard M. Lewis Ship updated TAP5-640:
--------------------------------------

    Summary: DOM manipulation during rendering can NPE  (was: DOM manipulation no longer allowed during rendering)

> DOM manipulation during rendering can NPE
> -----------------------------------------
>
>                 Key: TAP5-640
>                 URL: https://issues.apache.org/jira/browse/TAP5-640
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-core
>    Affects Versions: 5.1.0.2
>            Reporter: Dan Adams
>
> We have a number of utilities that do DOM manipulation while the page is rendering. This is often a lot easier than doing it after render and results in more concise code. An example is if you have a list of elements:
> <ul>
>   <li>foo</li>
>   <li></li>
>   <li></li>
> </ul>
> After each LI renders, do something like this:
> if (element.getChildren().isEmpty())
>   element.remove();
> It will work for the first empty LI and throw a NPE on the second empty LI because the container inside the element is null (which is odd since it just rendered into a container). But if you wait till after the LIs have all rendered you can loop back and do this safely. However, it's much less readable code and is a real bummer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.