aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2023-05-10 14:46:30 +0200
committerMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2023-05-10 17:34:14 +0200
commitba249efb6bee192d978a2f66eee4c717041f15fd (patch)
treecbcd0580373aa1e6577c45ae6072c3faffaf11fc
parent613b522e9a39e952823f205d347993b8fc8b350a (diff)
downloadjquery-ui-ba249efb6bee192d978a2f66eee4c717041f15fd.tar.gz
jquery-ui-ba249efb6bee192d978a2f66eee4c717041f15fd.zip
Tests: Workaround IE issues in qunit-assert-domequal
In IE, `option` elements may have different initial `option` colors. They may initially all be transparent, but later the selected option gets a blue background with white text; we now ignore it. The logic of `qunit-assert-domequal` was also fixed to use the same method of fetching styles in all browsers; IE used to get a legacy one meant for IE <9 due to a mistake in the performed check.
-rw-r--r--tests/lib/qunit-assert-domequal.js35
1 files changed, 19 insertions, 16 deletions
diff --git a/tests/lib/qunit-assert-domequal.js b/tests/lib/qunit-assert-domequal.js
index 066eb203b..bcce60702 100644
--- a/tests/lib/qunit-assert-domequal.js
+++ b/tests/lib/qunit-assert-domequal.js
@@ -38,6 +38,7 @@ var domEqual = QUnit.assert.domEqual = function( selector, modifier, message ) {
domEqual.properties = [
"disabled",
+ "nodeName",
"readOnly"
];
@@ -59,7 +60,6 @@ domEqual.attributes = [
"class",
"href",
"id",
- "nodeName",
"role",
"tabIndex",
"title"
@@ -76,23 +76,26 @@ function getElementStyles( elem ) {
var style = elem.ownerDocument.defaultView ?
elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
elem.currentStyle;
- var key, len;
-
- if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
- len = style.length;
- while ( len-- ) {
- key = style[ len ];
- if ( typeof style[ key ] === "string" ) {
- styles[ camelCase( key ) ] = style[ key ];
- }
+ var key, camelKey;
+ var len = style.length;
+
+ while ( len-- ) {
+ key = style[ len ];
+ camelKey = camelCase( key );
+
+ // Support: IE <=11+
+ // In IE, `option` elements may have different initial `option` colors.
+ // They may initially all be transparent, but later the selected
+ // option gets a blue background with white text; ignore it.
+ if ( document.documentMode && elem.nodeName.toLowerCase() === "option" && (
+ camelKey === "color" ||
+ camelKey.indexOf( "Color" ) === camelKey.length - "Color".length
+ ) ) {
+ continue;
}
- // Support: Opera, IE <9
- } else {
- for ( key in style ) {
- if ( typeof style[ key ] === "string" ) {
- styles[ key ] = style[ key ];
- }
+ if ( typeof style[ key ] === "string" ) {
+ styles[ camelKey ] = style[ key ];
}
}