Widget: Define this.document properly when instantiating a widget on a document or window. Fixes #7835 - Undefined property when creating widgets.

This commit is contained in:
Scott González 2011-11-07 08:39:22 -05:00
parent 900514ad0f
commit 8fd6101c3c

View File

@ -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 );
}