mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Tests: Skip CSS custom properties tests in non-supporting browsers
Ref 619bf98d5b
This commit is contained in:
parent
619bf98d5b
commit
bcec54ee72
@ -1556,8 +1556,14 @@ QUnit.test( "Do not throw on frame elements from css method (#15098)", function(
|
|||||||
|
|
||||||
} )();
|
} )();
|
||||||
|
|
||||||
|
( function() {
|
||||||
|
var supportsCssVars,
|
||||||
|
div = jQuery( "<div>" ).appendTo( "#qunit-fixture" )[ 0 ];
|
||||||
|
|
||||||
QUnit.test( "css(--customProperty)", function( assert ) {
|
div.style.setProperty( "--prop", "value" );
|
||||||
|
supportsCssVars = getComputedStyle( div ).getPropertyValue( "--prop" );
|
||||||
|
|
||||||
|
QUnit[ supportsCssVars ? "test" : "skip" ]( "css(--customProperty)", function( assert ) {
|
||||||
jQuery( "#qunit-fixture" ).append(
|
jQuery( "#qunit-fixture" ).append(
|
||||||
"<style>\n" +
|
"<style>\n" +
|
||||||
" .test__customProperties {\n" +
|
" .test__customProperties {\n" +
|
||||||
@ -1571,12 +1577,14 @@ QUnit.test( "css(--customProperty)", function( assert ) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
var div = jQuery( "<div>" ).appendTo( "#qunit-fixture" ),
|
var div = jQuery( "<div>" ).appendTo( "#qunit-fixture" ),
|
||||||
$elem = jQuery( "<div>" ).addClass( "test__customProperties" ).appendTo( "#qunit-fixture" ),
|
$elem = jQuery( "<div>" ).addClass( "test__customProperties" )
|
||||||
|
.appendTo( "#qunit-fixture" ),
|
||||||
webkit = /\bsafari\b/i.test( navigator.userAgent ) &&
|
webkit = /\bsafari\b/i.test( navigator.userAgent ) &&
|
||||||
!/\firefox\b/i.test( navigator.userAgent ) &&
|
!/\firefox\b/i.test( navigator.userAgent ) &&
|
||||||
!/\edge\b/i.test( navigator.userAgent ),
|
!/\edge\b/i.test( navigator.userAgent ),
|
||||||
oldSafari = webkit && ( /\b9\.\d(\.\d+)* safari/i.test( navigator.userAgent ) ||
|
oldSafari = webkit && ( /\b9\.\d(\.\d+)* safari/i.test( navigator.userAgent ) ||
|
||||||
/\b10\.0(\.\d+)* safari/i.test( navigator.userAgent ) ),
|
/\b10\.0(\.\d+)* safari/i.test( navigator.userAgent ) ||
|
||||||
|
/iphone os (?:9|10)_/i.test( navigator.userAgent ) ),
|
||||||
expected = 10;
|
expected = 10;
|
||||||
|
|
||||||
if ( webkit ) {
|
if ( webkit ) {
|
||||||
@ -1597,10 +1605,12 @@ QUnit.test( "css(--customProperty)", function( assert ) {
|
|||||||
assert.equal( div.css( "--color" ), "red", "Modified CSS custom property using object" );
|
assert.equal( div.css( "--color" ), "red", "Modified CSS custom property using object" );
|
||||||
|
|
||||||
div.css( { "--mixedCase": "green" } );
|
div.css( { "--mixedCase": "green" } );
|
||||||
assert.equal( div.css( "--mixedCase" ), "green", "Modified CSS custom property with mixed case" );
|
assert.equal( div.css( "--mixedCase" ), "green",
|
||||||
|
"Modified CSS custom property with mixed case" );
|
||||||
|
|
||||||
div.css( { "--theme-dark": "purple" } );
|
div.css( { "--theme-dark": "purple" } );
|
||||||
assert.equal( div.css( "--theme-dark" ), "purple", "Modified CSS custom property with dashed name" );
|
assert.equal( div.css( "--theme-dark" ), "purple",
|
||||||
|
"Modified CSS custom property with dashed name" );
|
||||||
|
|
||||||
assert.equal( $elem.css( "--prop1" ), "val1", "Basic CSS custom property" );
|
assert.equal( $elem.css( "--prop1" ), "val1", "Basic CSS custom property" );
|
||||||
|
|
||||||
@ -1619,5 +1629,6 @@ QUnit.test( "css(--customProperty)", function( assert ) {
|
|||||||
assert.equal( $elem.css( "--prop5" ), "'val5'", "Works with single quotes" );
|
assert.equal( $elem.css( "--prop5" ), "'val5'", "Works with single quotes" );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
} )();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user