Permalink
Browse files

Enhancer: Install when $.Widget is created

Closes gh-8308
  • Loading branch information...
gabrielschulhof authored and arschmitz committed Oct 17, 2015
1 parent dac76d2 commit 47e620907a0f66628268168146e7b93eca9a9586
Showing with 21 additions and 9 deletions.
  1. +0 −3 js/init.js
  2. +21 −6 js/widgets/enhancer.js
View
@@ -96,9 +96,6 @@ $.extend( $.mobile, {
// define first page in dom case one backs out to the directory root (not always the first page visited, but defined as fallback)
$.mobile.firstPage = $pages.first();
// Ensure the widget factory takes into account option values stored as data-attributes
$.enhance._installWidget();
// define page container
$.mobile.pageContainer = $.mobile.firstPage
.parent()
View
@@ -25,7 +25,8 @@
}
} )( function( $ ) {
var installed = false;
var widgetBaseClass,
installed = false;
$.fn.extend( {
enhance: function() {
@@ -53,10 +54,6 @@ $.extend( $.enhance, {
enhanceables = $.enhance._filter( enhanceables );
}
// Check if the widget factory exists and if it
// does make sure the options extension is installed
$.enhance._installWidget();
// Loop over and execute any hooks that exist
for ( i = 0; i < $.enhance.hooks.length; i++ ) {
$.enhance.hooks[ i ].call( elem, enhanceables );
@@ -172,7 +169,25 @@ $.extend( $.enhance, {
}
} );
$.enhance._installWidget();
if ( !$.Widget ) {
Object.defineProperty( $, "Widget", {
configurable: true,
enumerable: true,
get: function() {
return widgetBaseClass;
},
set: function( newValue ) {
if ( newValue ) {
widgetBaseClass = newValue;
setTimeout( function() {
$.enhance._installWidget();
} );
}
}
} );
} else {
$.enhance._installWidget();
}
return $.enhance;
} );

0 comments on commit 47e6209

Please sign in to comment.