Skip to content
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

Widget: Make contextless widget construction work #2019

Merged
merged 1 commit into from
Nov 18, 2021

Conversation

mgol
Copy link
Member

@mgol mgol commented Nov 18, 2021

Due to the fact the widget factory code is now in strict mode, the check for
being called without using the new keyword started breaking if you save the
widget constructor to a variable before calling it:

var customWidget = $.custom.customWidget;
customWidget( {}, elem );

as then this is undefined and checking for this._createWidget crashes.
Account for that with an additional check.

Fixes gh-2015

Due to the fact the widget factory code is now in strict mode, the check for
being called without using the `new` keyword started breaking if you save the
widget constructor to a variable before calling it:
```js
var customWidget = $.custom.customWidget;
customWidget( {}, elem );
```
as then `this` is undefined and checking for `this._createWidget` crashes.
Account for that with an additional check.

Fixes jquerygh-2015
@mgol mgol added this to the 1.13.1 milestone Nov 18, 2021
@mgol mgol requested a review from fnagel November 18, 2021 22:43
@mgol mgol self-assigned this Nov 18, 2021
Copy link
Member

@fnagel fnagel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 by reading

@mgol mgol merged commit ed637b0 into jquery:main Nov 18, 2021
@mgol mgol deleted the contextless-construction-gh-2015 branch November 18, 2021 23:47
@mgol
Copy link
Member Author

mgol commented Jan 20, 2022

jQuery UI 1.13.1 including this fix has been released: https://blog.jqueryui.com/2022/01/jquery-ui-1-13-1-released/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

jQuery-UI widget breaks if using as a module
3 participants