mirror of
https://github.com/jquery/jquery.git
synced 2026-01-25 09:47:59 -05:00
Only try to get data attributes for a jQuery-wrapped object if it is actually an Element node. Fixes #7524.
This commit is contained in:
16
src/data.js
16
src/data.js
@@ -138,15 +138,17 @@ jQuery.fn.extend({
|
||||
|
||||
if ( typeof key === "undefined" ) {
|
||||
if ( this.length ) {
|
||||
var attr = this[0].attributes, name;
|
||||
data = jQuery.data( this[0] );
|
||||
|
||||
for ( var i = 0, l = attr.length; i < l; i++ ) {
|
||||
name = attr[i].name;
|
||||
|
||||
if ( name.indexOf( "data-" ) === 0 ) {
|
||||
name = name.substr( 5 );
|
||||
dataAttr( this[0], name, data[ name ] );
|
||||
if ( this[0].nodeType === 1 ) {
|
||||
var attr = this[0].attributes, name;
|
||||
for ( var i = 0, l = attr.length; i < l; i++ ) {
|
||||
name = attr[i].name;
|
||||
|
||||
if ( name.indexOf( "data-" ) === 0 ) {
|
||||
name = name.substr( 5 );
|
||||
dataAttr( this[0], name, data[ name ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user