Skip to content

Commit ba249ef

Browse files
committed
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.
1 parent 613b522 commit ba249ef

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

tests/lib/qunit-assert-domequal.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ var domEqual = QUnit.assert.domEqual = function( selector, modifier, message ) {
3838

3939
domEqual.properties = [
4040
"disabled",
41+
"nodeName",
4142
"readOnly"
4243
];
4344

@@ -59,7 +60,6 @@ domEqual.attributes = [
5960
"class",
6061
"href",
6162
"id",
62-
"nodeName",
6363
"role",
6464
"tabIndex",
6565
"title"
@@ -76,23 +76,26 @@ function getElementStyles( elem ) {
7676
var style = elem.ownerDocument.defaultView ?
7777
elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
7878
elem.currentStyle;
79-
var key, len;
80-
81-
if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
82-
len = style.length;
83-
while ( len-- ) {
84-
key = style[ len ];
85-
if ( typeof style[ key ] === "string" ) {
86-
styles[ camelCase( key ) ] = style[ key ];
87-
}
79+
var key, camelKey;
80+
var len = style.length;
81+
82+
while ( len-- ) {
83+
key = style[ len ];
84+
camelKey = camelCase( key );
85+
86+
// Support: IE <=11+
87+
// In IE, `option` elements may have different initial `option` colors.
88+
// They may initially all be transparent, but later the selected
89+
// option gets a blue background with white text; ignore it.
90+
if ( document.documentMode && elem.nodeName.toLowerCase() === "option" && (
91+
camelKey === "color" ||
92+
camelKey.indexOf( "Color" ) === camelKey.length - "Color".length
93+
) ) {
94+
continue;
8895
}
8996

90-
// Support: Opera, IE <9
91-
} else {
92-
for ( key in style ) {
93-
if ( typeof style[ key ] === "string" ) {
94-
styles[ key ] = style[ key ];
95-
}
97+
if ( typeof style[ key ] === "string" ) {
98+
styles[ camelKey ] = style[ key ];
9699
}
97100
}
98101

0 commit comments

Comments
 (0)