mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Tests: Differentiate between attributes and properties in domEqual().
This commit is contained in:
parent
0bbad349b9
commit
649a670d1c
@ -138,12 +138,16 @@ TestHelpers.commonWidgetTests = function( widget, settings ) {
|
|||||||
/*
|
/*
|
||||||
* Experimental assertion for comparing DOM objects.
|
* Experimental assertion for comparing DOM objects.
|
||||||
*
|
*
|
||||||
* Serializes an element and some properties and it's children if any, otherwise the text.
|
* Serializes an element and some properties and attributes and it's children if any, otherwise the text.
|
||||||
* Then compares the result using deepEqual.
|
* Then compares the result using deepEqual.
|
||||||
*/
|
*/
|
||||||
window.domEqual = function( selector, modifier, message ) {
|
window.domEqual = function( selector, modifier, message ) {
|
||||||
var expected, actual,
|
var expected, actual,
|
||||||
properties = [
|
properties = [
|
||||||
|
"disabled",
|
||||||
|
"readOnly"
|
||||||
|
],
|
||||||
|
attributes = [
|
||||||
"autocomplete",
|
"autocomplete",
|
||||||
"aria-activedescendant",
|
"aria-activedescendant",
|
||||||
"aria-controls",
|
"aria-controls",
|
||||||
@ -159,11 +163,9 @@ window.domEqual = function( selector, modifier, message ) {
|
|||||||
"aria-valuemin",
|
"aria-valuemin",
|
||||||
"aria-valuenow",
|
"aria-valuenow",
|
||||||
"class",
|
"class",
|
||||||
"disabled",
|
|
||||||
"href",
|
"href",
|
||||||
"id",
|
"id",
|
||||||
"nodeName",
|
"nodeName",
|
||||||
"readOnly",
|
|
||||||
"role",
|
"role",
|
||||||
"tabIndex",
|
"tabIndex",
|
||||||
"title"
|
"title"
|
||||||
@ -179,7 +181,12 @@ window.domEqual = function( selector, modifier, message ) {
|
|||||||
var children,
|
var children,
|
||||||
result = {};
|
result = {};
|
||||||
$.each( properties, function( index, attr ) {
|
$.each( properties, function( index, attr ) {
|
||||||
result[ attr ] = elem.prop( attr );
|
var value = elem.prop( attr );
|
||||||
|
result[ attr ] = value !== undefined ? value : "";
|
||||||
|
});
|
||||||
|
$.each( attributes, function( index, attr ) {
|
||||||
|
var value = elem.attr( attr );
|
||||||
|
result[ attr ] = value !== undefined ? value : "";
|
||||||
});
|
});
|
||||||
children = elem.children();
|
children = elem.children();
|
||||||
if ( children.length ) {
|
if ( children.length ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user