Esanders has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/249424

Change subject: Tests: Refactor property->attribute copying
......................................................................

Tests: Refactor property->attribute copying

Change-Id: I35ff9df50186d0985e1d1f8f42a41d8a5497ed5b
---
M tests/QUnit.assert.equalDomElement.js
1 file changed, 15 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/24/249424/1

diff --git a/tests/QUnit.assert.equalDomElement.js 
b/tests/QUnit.assert.equalDomElement.js
index 9f11caa..fd63cfe 100644
--- a/tests/QUnit.assert.equalDomElement.js
+++ b/tests/QUnit.assert.equalDomElement.js
@@ -23,7 +23,7 @@
         * @return {Object} Summary of element.
         */
        function getDomElementSummary( element, includeHtml ) {
-               var i, name,
+               var i, name, attribute, property,
                        summary = {
                                type: element.nodeName.toLowerCase(),
                                // $( '<div><textarea>Foo</textarea></div>' 
)[0].textContent === 'Foo', which breaks
@@ -31,6 +31,15 @@
                                // text: element.textContent,
                                attributes: {},
                                children: []
+                       },
+                       // This is used to gather certain properties and 
pretend they are attributes.
+                       // Take note of casing differences.
+                       propertyAttributes = {
+                               value: 'value',
+                               readOnly: 'readonly',
+                               checked: 'checked',
+                               disabled: 'disabled',
+                               tabIndex: 'tabindex'
                        };
 
                if ( includeHtml && element.nodeType === Node.ELEMENT_NODE ) {
@@ -52,22 +61,11 @@
                        summary.attributes.class = 
summary.attributes.class.split( ' ' ).sort().join( ' ' );
                }
 
-               // Gather certain properties and pretend they are attributes.
-               // Take note of casing differences.
-               if ( element.value !== undefined ) {
-                       summary.attributes.value = element.value;
-               }
-               if ( element.readOnly !== undefined ) {
-                       summary.attributes.readonly = element.readOnly;
-               }
-               if ( element.checked !== undefined ) {
-                       summary.attributes.checked = element.checked;
-               }
-               if ( element.disabled !== undefined ) {
-                       summary.attributes.disabled = element.disabled;
-               }
-               if ( element.tabIndex !== undefined ) {
-                       summary.attributes.tabindex = element.tabIndex;
+               for ( property in propertyAttributes ) {
+                       attribute = propertyAttributes[ property ];
+                       if ( element[ property ] !== undefined ) {
+                               summary.attributes[ attribute ] = element[ 
property ];
+                       }
                }
 
                // Summarize children

-- 
To view, visit https://gerrit.wikimedia.org/r/249424
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I35ff9df50186d0985e1d1f8f42a41d8a5497ed5b
Gerrit-PatchSet: 1
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to