From 0423093de746fd6a4fb2458044a0643725712d63 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Tue, 4 Nov 2014 00:00:20 +0000 Subject: [PATCH] jquery.getAttrs: Replace deprecated nodeName/nodeValue with Attr.name/value Chrome emits the following warning: > 'Attr.nodeValue' is deprecated. Please use 'value' instead. Attr.nodeName and nodeValue are not part of the DOM standard. https://dom.spec.whatwg.org/#interface-attr Attr.name and Attr.value are supported since at least IE8. Confirmed the unit tests passing in IE8. Simplify and improve the unit tests for jquery.getAttrs. Change-Id: Ic086ece34b214dede26371cbc03ede0f2af37c54 --- resources/src/jquery/jquery.getAttrs.js | 2 +- .../qunit/suites/resources/jquery/jquery.getAttrs.test.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/resources/src/jquery/jquery.getAttrs.js b/resources/src/jquery/jquery.getAttrs.js index 5ad76480cd..5d6a1d442e 100644 --- a/resources/src/jquery/jquery.getAttrs.js +++ b/resources/src/jquery/jquery.getAttrs.js @@ -17,7 +17,7 @@ jQuery.fn.getAttrs = function () { len = map.length; for ( i = 0; i < len; i++ ) { - attrs[ map[i].nodeName ] = map[i].nodeValue; + attrs[ map[i].name ] = map[i].value; } return attrs; diff --git a/tests/qunit/suites/resources/jquery/jquery.getAttrs.test.js b/tests/qunit/suites/resources/jquery/jquery.getAttrs.test.js index 0b7e87ee21..ca3f418c31 100644 --- a/tests/qunit/suites/resources/jquery/jquery.getAttrs.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.getAttrs.test.js @@ -1,13 +1,14 @@ ( function ( $ ) { QUnit.module( 'jquery.getAttrs', QUnit.newMwEnvironment() ); - QUnit.test( 'Check', 1, function ( assert ) { + QUnit.test( 'getAttrs()', 1, function ( assert ) { var attrs = { foo: 'bar', - 'class': 'lorem' + 'class': 'lorem', + 'data-foo': 'data value' }, $el = $( '
' ).attr( attrs ); - assert.deepEqual( $el.getAttrs(), attrs, 'getAttrs() return object should match the attributes set, no more, no less' ); + assert.propEqual( $el.getAttrs(), attrs, 'keys and values match' ); } ); }( jQuery ) ); -- 2.20.1