Skip to content

Commit 1beb8a9

Browse files
committed
Add _superApply method and use it in a few places
1 parent 79b5f06 commit 1beb8a9

File tree

8 files changed

+28
-8
lines changed

8 files changed

+28
-8
lines changed

tests/unit/widget/widget.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,20 @@ test("_super", function() {
182182
$("<div></div>").child().child("log");
183183
});
184184

185+
test("_superApply", function() {
186+
expect(2);
187+
$.widget("sup.parent", {
188+
log: function(a, b) {
189+
same( a, 1 );
190+
same( b, 2 );
191+
}
192+
});
193+
$.widget("sup.child", $.sup.parent, {
194+
log: function() {
195+
this._superApply("log", arguments);
196+
}
197+
});
198+
$("<div></div>").child().child("log", 1, 2);
199+
});
200+
185201
})(jQuery);

ui/jquery.ui.accordion.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ $.widget("ui.accordion", {
151151
},
152152

153153
_setOption: function(key, value) {
154-
$.Widget.prototype._setOption.apply(this, arguments);
154+
this._superApply( "_setOption", arguments );
155155

156156
if (key == "active") {
157157
this.activate(value);

ui/jquery.ui.autocomplete.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ $.widget( "ui.autocomplete", {
167167
},
168168

169169
_setOption: function( key ) {
170-
$.Widget.prototype._setOption.apply( this, arguments );
170+
this._superApply( "_setOption", arguments );
171171
if ( key === "source" ) {
172172
this._initSource();
173173
}

ui/jquery.ui.button.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ $.widget( "ui.button", {
230230
},
231231

232232
_setOption: function( key, value ) {
233-
$.Widget.prototype._setOption.apply( this, arguments );
233+
this._superApply( "_setOption", arguments );
234234
if ( key === "disabled" ) {
235235
if ( value ) {
236236
this.element.attr( "disabled", true );
@@ -324,7 +324,7 @@ $.widget( "ui.buttonset", {
324324
this.buttons.button( "option", key, value );
325325
}
326326

327-
$.Widget.prototype._setOption.apply( this, arguments );
327+
this._superApply( "_setOption", arguments );
328328
},
329329

330330
refresh: function() {

ui/jquery.ui.progressbar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ $.widget( "ui.progressbar", {
4343

4444
this.valueDiv.remove();
4545

46-
$.Widget.prototype.destroy.apply( this, arguments );
46+
this._superApply( "destroy", arguments );
4747
},
4848

4949
value: function( newValue ) {
@@ -64,7 +64,7 @@ $.widget( "ui.progressbar", {
6464
break;
6565
}
6666

67-
$.Widget.prototype._setOption.apply( this, arguments );
67+
this._superApply( "_setOption", arguments );
6868
},
6969

7070
_value: function() {

ui/jquery.ui.slider.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ $.widget( "ui.slider", $.ui.mouse, {
511511
valsLength = this.options.values.length;
512512
}
513513

514-
$.Widget.prototype._setOption.apply( this, arguments );
514+
this._superApply( "_setOption", arguments );
515515

516516
switch ( key ) {
517517
case "disabled":

ui/jquery.ui.sortable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ $.widget("ui.sortable", $.ui.mouse, {
8181
[ value ? "addClass" : "removeClass"]( "ui-sortable-disabled" );
8282
} else {
8383
// Don't call widget base _setOption for disable as it adds ui-state-disabled class
84-
$.Widget.prototype._setOption.apply(this, arguments);
84+
this._superApply( "_setOption", arguments );
8585
}
8686
},
8787

ui/jquery.ui.widget.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ $.Widget.prototype = {
151151
this.base[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ) );
152152
},
153153

154+
_superApply: function( method, args ) {
155+
this.base[ method ].apply( this, args );
156+
},
157+
154158
destroy: function() {
155159
this.element
156160
.unbind( "." + this.widgetName )

0 commit comments

Comments
 (0)