Skip to content

Commit 649a670

Browse files
committed
Tests: Differentiate between attributes and properties in domEqual().
1 parent 0bbad34 commit 649a670

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

tests/unit/testsuite.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,16 @@ TestHelpers.commonWidgetTests = function( widget, settings ) {
138138
/*
139139
* Experimental assertion for comparing DOM objects.
140140
*
141-
* Serializes an element and some properties and it's children if any, otherwise the text.
141+
* Serializes an element and some properties and attributes and it's children if any, otherwise the text.
142142
* Then compares the result using deepEqual.
143143
*/
144144
window.domEqual = function( selector, modifier, message ) {
145145
var expected, actual,
146146
properties = [
147+
"disabled",
148+
"readOnly"
149+
],
150+
attributes = [
147151
"autocomplete",
148152
"aria-activedescendant",
149153
"aria-controls",
@@ -159,11 +163,9 @@ window.domEqual = function( selector, modifier, message ) {
159163
"aria-valuemin",
160164
"aria-valuenow",
161165
"class",
162-
"disabled",
163166
"href",
164167
"id",
165168
"nodeName",
166-
"readOnly",
167169
"role",
168170
"tabIndex",
169171
"title"
@@ -179,7 +181,12 @@ window.domEqual = function( selector, modifier, message ) {
179181
var children,
180182
result = {};
181183
$.each( properties, function( index, attr ) {
182-
result[ attr ] = elem.prop( attr );
184+
var value = elem.prop( attr );
185+
result[ attr ] = value !== undefined ? value : "";
186+
});
187+
$.each( attributes, function( index, attr ) {
188+
var value = elem.attr( attr );
189+
result[ attr ] = value !== undefined ? value : "";
183190
});
184191
children = elem.children();
185192
if ( children.length ) {

0 commit comments

Comments
 (0)