diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 578d330ba..56f465b94 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -195,7 +195,11 @@ $.Widget.prototype = { if ( element !== this ) { $.data( element, this.widgetName, this ); this._bind({ remove: "destroy" }); - this.document = $( element.ownerDocument ); + this.document = $( element.style ? + // element within the document + element.ownerDocument : + // element is window or document + element.document || element ); this.window = $( this.document[0].defaultView || this.document[0].parentWindow ); }