Skip to content

Commit 1abf9fc

Browse files
arschmitzscottgonzalez
authored andcommitted
Widget: Ensure window and document are defined in _getCreateOptions()
Closes gh-1320
1 parent bfb6507 commit 1abf9fc

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

tests/unit/widget/widget_core.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,17 @@ test( "merge multiple option arguments", function() {
260260
});
261261

262262
test( "._getCreateOptions()", function() {
263-
expect( 1 );
263+
expect( 3 );
264264
$.widget( "ui.testWidget", {
265265
options: {
266266
option1: "valuex",
267267
option2: "valuex",
268268
option3: "value3"
269269
},
270270
_getCreateOptions: function() {
271+
strictEqual( this.window[ 0 ], window, "this.window is properly defined" );
272+
strictEqual( this.document[ 0 ], document, "this.document is properly defined" );
273+
271274
return {
272275
option1: "override1",
273276
option2: "overideX"

ui/widget.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,6 @@ $.Widget.prototype = {
254254
this.element = $( element );
255255
this.uuid = widget_uuid++;
256256
this.eventNamespace = "." + this.widgetName + this.uuid;
257-
this.options = $.widget.extend( {},
258-
this.options,
259-
this._getCreateOptions(),
260-
options );
261257

262258
this.bindings = $();
263259
this.hoverable = $();
@@ -280,6 +276,11 @@ $.Widget.prototype = {
280276
this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
281277
}
282278

279+
this.options = $.widget.extend( {},
280+
this.options,
281+
this._getCreateOptions(),
282+
options );
283+
283284
this._create();
284285
this._trigger( "create", null, this._getCreateEventData() );
285286
this._init();

0 commit comments

Comments
 (0)