Skip to content

Commit 6381b4a

Browse files
authored
Merge branch 'jquery:main' into master
2 parents 237f507 + ed637b0 commit 6381b4a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

tests/unit/widget/core.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ QUnit.test( "element normalization", function( assert ) {
9292
$.ui.testWidget();
9393
} );
9494

95+
QUnit.test( "contextless construction", function( assert ) {
96+
assert.expect( 1 );
97+
var testWidget,
98+
elem = $( "<div>" );
99+
100+
$.widget( "ui.testWidget", {} );
101+
testWidget = $.ui.testWidget;
102+
103+
testWidget( {}, elem );
104+
assert.ok( true, "No crash" );
105+
} );
106+
95107
QUnit.test( "custom selector expression", function( assert ) {
96108
assert.expect( 1 );
97109
var elem = $( "<div>" ).appendTo( "#qunit-fixture" );

ui/widget.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ $.widget = function( name, base, prototype ) {
7777
constructor = $[ namespace ][ name ] = function( options, element ) {
7878

7979
// Allow instantiation without "new" keyword
80-
if ( !this._createWidget ) {
80+
if ( !this || !this._createWidget ) {
8181
return new constructor( options, element );
8282
}
8383

0 commit comments

Comments
 (0)