]> source.dussan.org Git - jquery-ui.git/commitdiff
Widget: Ensure window and document are defined in _getCreateOptions()
authorAlexander Schmitz <arschmitz@gmail.com>
Thu, 21 Aug 2014 13:02:45 +0000 (09:02 -0400)
committerScott González <scott.gonzalez@gmail.com>
Wed, 27 Aug 2014 13:08:01 +0000 (09:08 -0400)
Closes gh-1320

tests/unit/widget/widget_core.js
ui/widget.js

index 2fdb9bc76e00f63001c242bead0170dd880e47ac..6b5cdeaa36429508ca529edf7c8670b47e9ae783 100644 (file)
@@ -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"
index 6ef161591f5c78bd63f8a6281ed8f27b52ebf836..41425b1a9d3ea8ea6ea3d5a1f84b56fed2be0b8c 100644 (file)
@@ -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();