Merge branch 'bug7524' of https://github.com/csnover/jquery into csnover-bug7524
This commit is contained in:
commit
8943b427f6
16
src/data.js
16
src/data.js
|
@ -138,15 +138,17 @@ jQuery.fn.extend({
|
||||||
|
|
||||||
if ( typeof key === "undefined" ) {
|
if ( typeof key === "undefined" ) {
|
||||||
if ( this.length ) {
|
if ( this.length ) {
|
||||||
var attr = this[0].attributes, name;
|
|
||||||
data = jQuery.data( this[0] );
|
data = jQuery.data( this[0] );
|
||||||
|
|
||||||
for ( var i = 0, l = attr.length; i < l; i++ ) {
|
if ( this[0].nodeType === 1 ) {
|
||||||
name = attr[i].name;
|
var attr = this[0].attributes, name;
|
||||||
|
for ( var i = 0, l = attr.length; i < l; i++ ) {
|
||||||
if ( name.indexOf( "data-" ) === 0 ) {
|
name = attr[i].name;
|
||||||
name = name.substr( 5 );
|
|
||||||
dataAttr( this[0], name, data[ name ] );
|
if ( name.indexOf( "data-" ) === 0 ) {
|
||||||
|
name = name.substr( 5 );
|
||||||
|
dataAttr( this[0], name, data[ name ] );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ test("jQuery.data", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test(".data()", function() {
|
test(".data()", function() {
|
||||||
expect(4);
|
expect(5);
|
||||||
|
|
||||||
var div = jQuery("#foo");
|
var div = jQuery("#foo");
|
||||||
strictEqual( div.data("foo"), undefined, "Make sure that missing result is undefined" );
|
strictEqual( div.data("foo"), undefined, "Make sure that missing result is undefined" );
|
||||||
|
@ -90,6 +90,9 @@ test(".data()", function() {
|
||||||
|
|
||||||
var nodiv = jQuery("#unfound");
|
var nodiv = jQuery("#unfound");
|
||||||
equals( nodiv.data(), null, "data() on empty set returns null" );
|
equals( nodiv.data(), null, "data() on empty set returns null" );
|
||||||
|
|
||||||
|
var obj = { foo: "bar" };
|
||||||
|
equals( jQuery(obj).data(), obj, "Retrieve data object from a wrapped JS object (#7524)" );
|
||||||
})
|
})
|
||||||
|
|
||||||
test(".data(String) and .data(String, Object)", function() {
|
test(".data(String) and .data(String, Object)", function() {
|
||||||
|
|
Loading…
Reference in a new issue