Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

AbstractContainer.RemoveAll() server-side call adds 'null' argument to the client-side call #1573

Closed
fabriciomurta opened this issue Feb 1, 2018 · 2 comments
Assignees
Milestone

Comments

@fabriciomurta
Copy link
Contributor

Found: 4.5.1
Ext.NET forum thread: RemoveAll() causes a Javascript Error on subsequent calls

Calling any containter's RemoveAll() method makes it emit removeAll(null) unless true/false is provided as paramemter to the call. This makes the client-side code misinterpret the null argument as an object and try to reference null.destroy, thus triggering a run time exception.

Test case to reproduce the issue:

<%@ Page Language="C#" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
        }
    }

    protected void Unnamed_Event(object sender, DirectEventArgs e)
    {
        if (X.IsAjaxRequest)
        {
            this.MenuDynItems.RemoveAll();

            for (int i = 1; i < 5; i++)
            {
                var mi = new Ext.Net.MenuItem() { ID = "dynExt-00" + i, Text = "Item 00" + i, IDMode = IDMode.Static };
                mi.Listeners.Click.Handler = string.Format("alert('{0}')", mi.Text);
                this.MenuDynItems.Items.Add(mi);
                mi.Render();
            }
            this.WinTest.Show();
        }
    }
</script>
<head>
    <title></title>
    <script type="text/javascript">
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <ext:ResourceManager runat="server" ID="rm1" ShowWarningOnAjaxFailure="true" Theme="Triton"></ext:ResourceManager>
        <ext:Button runat="server" Text="Launch Window">
            <DirectEvents>
                <Click OnEvent="Unnamed_Event" />
            </DirectEvents>
        </ext:Button>
        <ext:Window ID="WinTest" runat="server" Hidden="true" CloseAction="Hide" Title="Testing Dynamically Added Items" Height="200" Width="300">
            <Items>
                <ext:SplitButton runat="server" ID="ButtonTest" Text="Dynamic Added Items">
                    <Menu>
                        <ext:Menu ID="MenuDynItems" runat="server">
                        </ext:Menu>
                    </Menu>
                </ext:SplitButton>
            </Items>
        </ext:Window>
    </form>
</body>
</html>

To reproduce the issue, just click twice the 'launch window' button. First time it does not trigger the issue because there's nothing to be removed at all, so the breaking test is never triggered. Second time, as there are items within the container, then the error arises.

This issue is Ext.NET-specific.

@fabriciomurta fabriciomurta added this to the 4.x milestone Feb 1, 2018
@fabriciomurta
Copy link
Contributor Author

Interesting to add, calling anything without parameters seems to add the null argument (which is not really equivalent to undefined, or absent.
this.MenuDynItems.Call("getHeader");
this.MenuDynItems.Call("removeAll");

It seems this is a common practice by Ext.NET that just in this case has resulted in an error.

@fabriciomurta fabriciomurta modified the milestones: 4.x, 4.6.0 Jun 15, 2018
@fabriciomurta
Copy link
Contributor Author

We've just fixed the issue in latest Ext.NET sources! The fix will make it to next publicly available Ext.NET release.

@fabriciomurta fabriciomurta self-assigned this Jun 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant