From 1abf9fc71f11996168fd81da7ebf25218f5ad4a4 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Thu, 21 Aug 2014 09:02:45 -0400 Subject: [PATCH] Widget: Ensure window and document are defined in _getCreateOptions() Closes gh-1320 --- tests/unit/widget/widget_core.js | 5 ++++- ui/widget.js | 9 +++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js index 2fdb9bc76..6b5cdeaa3 100644 --- a/tests/unit/widget/widget_core.js +++ b/tests/unit/widget/widget_core.js @@ -260,7 +260,7 @@ test( "merge multiple option arguments", function() { }); test( "._getCreateOptions()", function() { - expect( 1 ); + expect( 3 ); $.widget( "ui.testWidget", { options: { option1: "valuex", @@ -268,6 +268,9 @@ test( "._getCreateOptions()", function() { option3: "value3" }, _getCreateOptions: function() { + strictEqual( this.window[ 0 ], window, "this.window is properly defined" ); + strictEqual( this.document[ 0 ], document, "this.document is properly defined" ); + return { option1: "override1", option2: "overideX" diff --git a/ui/widget.js b/ui/widget.js index 6ef161591..41425b1a9 100644 --- a/ui/widget.js +++ b/ui/widget.js @@ -254,10 +254,6 @@ $.Widget.prototype = { this.element = $( element ); this.uuid = widget_uuid++; this.eventNamespace = "." + this.widgetName + this.uuid; - this.options = $.widget.extend( {}, - this.options, - this._getCreateOptions(), - options ); this.bindings = $(); this.hoverable = $(); @@ -280,6 +276,11 @@ $.Widget.prototype = { this.window = $( this.document[0].defaultView || this.document[0].parentWindow ); } + this.options = $.widget.extend( {}, + this.options, + this._getCreateOptions(), + options ); + this._create(); this._trigger( "create", null, this._getCreateEventData() ); this._init(); -- 2.39.5