Ticket #5041 (closed bug: fixed)

Opened 5 years ago

Last modified 5 years ago

Stack overflow when jquery-ui.js included twice

Reported by: glipman Owned by:
Priority: minor Milestone: 1.8
Component: ui.position Version: 1.8a2
Keywords: stack overflow twice Cc:
Blocking: Blocked by:

Description

The following small sample creates a 'Stack overflow error' in Internet Explorer (or makes IE even crash hard) with 1.8a2.

<html>
    <head>
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript" src="ui/jquery-ui.js"></script>
        <script type="text/javascript" src="ui/jquery-ui.js"></script>
        <script>
            $(document).ready(function () { $("body").offset(1) } );
        </script>
    </head>
<body>
    Hello
</body>
</html>

It is caused by the redefinition of the offset-function. The old definition is stored in a variable _offset but when the second include is processed the old definition is identical to the new definition causing infinite recursion.

As a workaround I obviously cleaned my code so the js is included only once.
However I think jQuery-ui should be more robust (not crash) when it is included twice.

Change History

comment:1 Changed 5 years ago by scott.gonzalez

  • Status changed from new to closed
  • Resolution set to fixed
  • Component changed from ui.core to ui.position
  • Milestone changed from TBD to 1.8

The offset code in the 1.8 alphas was temporary (waiting for the offset setter code in jQuery 1.4). The new offset code was already landed in the dev branch and doesn't have this problem.

Note: See TracTickets for help on using tickets.