New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
fabriciomurta opened this Issue Feb 1, 2018 · 2 comments

Comments

Projects
None yet
1 participant
@fabriciomurta
Contributor

fabriciomurta commented Feb 1, 2018

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

This comment has been minimized.

Contributor

fabriciomurta commented Feb 1, 2018

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

This comment has been minimized.

Contributor

fabriciomurta commented Jun 15, 2018

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 join this conversation on GitHub. Already have an account? Sign in to comment