Skip to content

Commit e4084c4

Browse files
committed
Observable: Fix property method in combination with setting array properties. Was missing the oldValues.
1 parent 6e33cb7 commit e4084c4

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

tests/unit/observable/observable_core.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,13 @@ test( "key, value", function() {
1818
equal( object.name, "Pan" );
1919
});
2020

21+
test( "key, value on array", function() {
22+
var object = [ 1, 2, 3, 4, 5 ];
23+
$.observable( object ).bind( "change", function(event, ui) {
24+
deepEqual( ui.oldValues, { 2: 3 } );
25+
deepEqual( ui.newValues, { 2: 88 } );
26+
}).property( 2, 88 );
27+
equal( object[2], 88 );
28+
});
29+
2130
}( jQuery ) );

ui/jquery.ui.observable.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
if ( fields.length === 0 ) {
2929
return object;
3030
}
31+
if ( fields.length === undefined ) {
32+
return object[ fields ];
33+
}
3134
while ( fields.length > 1 ) {
3235
field = fields.shift();
3336
object = object[ field ];

0 commit comments

Comments
 (0)