-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Recent CSS WG decision w3c/csswg-drafts#3258 Bug: 568705 Change-Id: If24be4b2c0a49ba12c92df873b0a4de12eb1a21e
- Loading branch information
1 parent
9b65752
commit 7e9595a
Showing
4 changed files
with
24 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>CSS Selectors Invalidation: :matches()</title> | ||
<title>CSS Selectors Invalidation: :is()</title> | ||
<link rel="author" title="Victoria Su" href="mailto:[email protected]"> | ||
<link rel="help" href="https://drafts.csswg.org/selectors-4/#matches"> | ||
<meta name="assert" content="This tests that the :matches() selector is effective"> | ||
<meta name="assert" content="This tests that the :is() selector is effective"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<style> | ||
.b { | ||
color: yellow; | ||
} | ||
/*Simple selector arguments */ | ||
.a :matches(.b, .c) { | ||
.a :is(.b, .c) { | ||
color: red; | ||
} | ||
/*Compound selector arguments */ | ||
.a :matches(.c#d, .e) { | ||
.a :is(.c#d, .e) { | ||
color: green; | ||
} | ||
/* Complex selector arguments */ | ||
.a .g>.b { | ||
color: black; | ||
} | ||
.a :matches(.e+.f, .g>.b, .h) { | ||
.a :is(.e+.f, .g>.b, .h) { | ||
color: blue; | ||
} | ||
.g>.b { | ||
|
@@ -39,7 +39,7 @@ | |
.c>.a+.e { | ||
color: black; | ||
} | ||
.a+:matches(.b+.f, :matches(.c>.e, .g)) { | ||
.a+:is(.b+.f, :is(.c>.e, .g)) { | ||
color: red; | ||
} | ||
.c>.e { | ||
|
@@ -108,32 +108,32 @@ | |
assert_equals(getComputedStyle(b1).color, red); | ||
assert_equals(getComputedStyle(b3).color, red); | ||
assert_equals(getComputedStyle(c1).color, red); | ||
}, "Invalidate :matches() for simple selector arguments."); | ||
}, "Invalidate :is() for simple selector arguments."); | ||
|
||
test(() => { | ||
a1.className = "a"; | ||
assert_equals(getComputedStyle(d).color, green); | ||
}, "Invalidate :matches() for compound selector arguments."); | ||
}, "Invalidate :is() for compound selector arguments."); | ||
|
||
test(() => { | ||
a1.className = "a"; | ||
assert_equals(getComputedStyle(b2).color, blue); | ||
assert_equals(getComputedStyle(b3).color, red); | ||
assert_equals(getComputedStyle(f1).color, blue); | ||
}, "Invalidate :matches() for complex selector arguments."); | ||
}, "Invalidate :is() for complex selector arguments."); | ||
|
||
test(() => { | ||
a1.className = "a"; | ||
assert_equals(getComputedStyle(e2).color, black); | ||
a2.className = "a"; | ||
assert_equals(getComputedStyle(e2).color, red); | ||
}, "Invalidate nested :matches()."); | ||
}, "Invalidate nested :is()."); | ||
|
||
test(() => { | ||
a1.className = "a"; | ||
assert_equals(getComputedStyle(b2).color, blue); | ||
assert_equals(getComputedStyle(h1).color, black); | ||
}, "Test specificity of :matches()."); | ||
}, "Test specificity of :is()."); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>CSS Selectors: :matches()</title> | ||
<title>CSS Selectors: :is()</title> | ||
<link rel="author" title="Victoria Su" href="mailto:[email protected]"> | ||
<link rel="help" href="https://drafts.csswg.org/selectors-4/#matches"> | ||
<meta name="assert" content="This tests that the :matches() selector is effective when nested"> | ||
<meta name="assert" content="This tests that the :is() selector is effective when nested"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<style> | ||
/* Testing that highest specificity is chosen for class outside of :matches() */ | ||
/* Testing that highest specificity is chosen for class outside of :is() */ | ||
.a+.b+.c>.e+.d { | ||
color: black; | ||
font-size: 10px; | ||
width: 10px; | ||
} | ||
.a+:matches(.b+.f, .b+:matches(*, .c>.e, .g, *))+.d { | ||
.a+:is(.b+.f, .b+:is(*, .c>.e, .g, *))+.d { | ||
color: red; | ||
font-size: 20px; | ||
} | ||
.a+.b+.c>.e+.d { | ||
color: yellow; | ||
} | ||
/* Testing specificty of a class within :matches() */ | ||
/* Testing specificty of a class within :is() */ | ||
.a+.c>.e { | ||
color: black; | ||
} | ||
.a+:matches(.b+.f, :matches(.c>.e, .g)) { | ||
.a+:is(.b+.f, :is(.c>.e, .g)) { | ||
color: red; | ||
} | ||
.c>.e { | ||
|
@@ -61,11 +61,11 @@ | |
assert_equals(getComputedStyle(d1).color, yellow); | ||
assert_equals(getComputedStyle(d1).fontSize, "20px"); | ||
assert_equals(getComputedStyle(d1).width, "10px"); | ||
}, "Test nested :matches() chooses highest specificity for class outside :matches()."); | ||
}, "Test nested :is() chooses highest specificity for class outside :is()."); | ||
|
||
test(() => { | ||
assert_equals(getComputedStyle(e1).color, red); | ||
}, "Test nested :matches() specificity for class within arguments."); | ||
}, "Test nested :is() specificity for class within arguments."); | ||
|
||
</script> | ||
</body> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>CSS Selectors: :matches()</title> | ||
<title>CSS Selectors: :is()</title> | ||
<link rel="author" title="Victoria Su" href="mailto:[email protected]"> | ||
<link rel="help" href="https://drafts.csswg.org/selectors-4/#matches"> | ||
<meta name="assert" content="This tests that the :matches() selector chooses the correct specificity"> | ||
<meta name="assert" content="This tests that the :is() selector chooses the correct specificity"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<style> | ||
|
@@ -13,7 +13,7 @@ | |
height: 10px; | ||
width: 10px; | ||
} | ||
:matches(.a, .b.c + .d, .e) + :matches(* + .p, .q.r + .s, * + .t) + #target { | ||
:is(.a, .b.c + .d, .e) + :is(* + .p, .q.r + .s, * + .t) + #target { | ||
height: 20px; | ||
width: 20px; | ||
} | ||
|
@@ -34,7 +34,7 @@ | |
assert_equals(getComputedStyle(target).width, "30px"); | ||
assert_equals(getComputedStyle(target).height, "20px"); | ||
assert_equals(getComputedStyle(target).fontSize, "10px"); | ||
}, "Test :matches() uses highest possible specificity"); | ||
}, "Test :is() uses highest possible specificity"); | ||
|
||
</script> | ||
</body> | ||
|