if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
i = attrs.length;
while ( i-- ) {
- name = attrs[i].name;
- if ( name.indexOf("data-") === 0 ) {
- name = jQuery.camelCase( name.slice(5) );
-
- dataAttr( elem, name, data[ name ] );
+ // Support: IE11+
+ // The attrs elements can be null (#14894)
+ if ( attrs[ i ] ) {
+ name = attrs[ i ].name;
+ if ( name.indexOf( "data-" ) === 0 ) {
+ name = jQuery.camelCase( name.slice(5) );
+ dataAttr( elem, name, data[ name ] );
+ }
}
}
jQuery._data( elem, "parsedAttrs", true );
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>IE11 onpageshow strangeness (#14894)</title>
+ <script src="../../jquery.js"></script>
+ <script>
+ $(function(){
+ window.parent.iframeCallback( $( "body" ).data().result );
+ });
+ </script>
+</head>
+<body x-what="test" data-result="ok" onload="x=1" onpageshow="x=1">
+ Test for #14894
+</body>
+</html>
equal( x.data("some").foo, "bar", "got a JSON data- attribute with spaces" );
x.remove();
});
+
+testIframeWithCallback( "enumerate data attrs on body (#14894)", "data/dataAttrs.html", function( result ) {
+ expect(1);
+
+ equal(result, "ok", "enumeration of data- attrs on body" );
+});
\ No newline at end of file