Skip to main content

Search and Top Navigation

#5041 closed bug (fixed)

Opened January 05, 2010 05:52PM UTC

Closed January 06, 2010 04:15AM UTC

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:
Blocked by: Blocking:
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.

Attachments (0)
Change History (1)

Changed January 06, 2010 04:15AM UTC by scottgonzalez comment:1

component: ui.coreui.position
milestone: TBD1.8
resolution: → fixed
status: newclosed

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.