From 2b42b64a79dad888b10316e79675e2b507883eed Mon Sep 17 00:00:00 2001 From: fantasai Date: Wed, 3 Oct 2018 13:53:15 -0700 Subject: [PATCH] [selectors-4] Define :empty to ignore whitespace. Define :blank to apply to empty inputs. #1967 #1283 --- selectors-4/Overview.bs | 102 +++++++++++++++++++++++----------------- 1 file changed, 60 insertions(+), 42 deletions(-) diff --git a/selectors-4/Overview.bs b/selectors-4/Overview.bs index 5b0d5257992..a90126d2031 100644 --- a/selectors-4/Overview.bs +++ b/selectors-4/Overview.bs @@ -397,7 +397,7 @@ Selectors Overview 3 E:empty - an E element that has no children (not even text nodes) + an E element that has no children (neither elements nor text) [[#structural-pseudos]] 3 @@ -2580,6 +2580,26 @@ The Indeterminate-value Pseudo-class: '':indeterminate''

Input Value-checking

+

+The Empty-Value Pseudo-class: '':blank''

+ + The :blank pseudo-class + applies to user-input elements whose input value is empty + (consists of the empty string or otherwise null input). + +
+ Examples of '':blank'' user-input elements would be + a <{textarea}> element whose contents are empty, + or an <{input}> field whose value is empty. + Note that the value under consideration here is the value + that would be submitted + (see A form control’s value in [[HTML]]), + which in HTML does not necessarily correspond to the value + of the element’s <{input/value}> attribute. +
+ + Note: This selector is at-risk. +

The Validity Pseudo-classes: '':valid'' and '':invalid''

@@ -2697,7 +2717,9 @@ Tree-Structural pseudo-classes

'':empty'' pseudo-class

- The :empty pseudo-class represents an element that has no children at all. + The :empty pseudo-class represents + an element that has no children + except, optionally, document white space characters. In terms of the document tree, only element nodes and content nodes (such as [[DOM]] text nodes, and entity references) @@ -2707,48 +2729,37 @@ Tree-Structural pseudo-classes
Examples: - ''p:empty'' is a valid representation of the following fragment: - -
<p></p>
- - ''foo:empty'' is not a valid representation for the - following fragments: - -
<foo>bar</foo>
- -
<foo><bar>bla</bar></foo>
- -
<foo>this is not <bar>:empty</bar></foo>
-
- - Issue: The WG is considering whether to allow elements containing only white space to match this selector. - The advantage would be that-- - as white space is largely collapsible in HTML and is therefore used for source code formatting, and especially because elements with omitted end tags are likely to absorb such white space into their DOM text contents-- - many elements which authors perceive of as empty would be selected by this selector, as they expect. - The disadvantages are a potential conflict with Web-compat if there exist pages that depend on this selector excluding white space; - and that one might consider uncollapsed white space to be significant content, but the selector cannot change its behavior based on the 'white-space' property. - See discussion. - - -

-'':blank'' pseudo-class

- - The :blank pseudo-class is like the '':empty'' pseudo-class, - except that it additionally matches elements that only contain - code points affected by whitespace processing. [[!CSS3TEXT]] + ''p:empty'' is a valid representation of the <{p}> elements + in the following HTML fragment: + +
+			<p></p>
+			<p>
+			<p> </p>
+			<p></p>
+		
-
- For example, the following element matches '':blank'', - but not '':empty'', - because it contains at least one linebreak, and possibly other whitespace: + ''div:empty'' is not a valid representation of the <div> elements + in the following fragment: -
<p>
</p>
+
+			<div>text</div>
+			<div><p></p></div>
+			<div>&nbsp;</div>
+			<div><p>bla</p></div>
+			<div>this is not <p>:empty</p></div>
+		
- Issue: The WG is considering whether to rename this or file its definition under the existing '':empty'' pseudo-class. - See discussion. - There's also a related issue on a selector for empty input fields which might legitimately steal this name. - + Note: In Level 2 and Level 3 of Selectors, + '':empty'' did not match elements that contained only white space. + This was changed so that that-- + given white space is largely collapsible in HTML + and is therefore used for source code formatting, + and especially because elements with omitted end tags + are likely to absorb such white space into their DOM text contents-- + elements which authors perceive of as empty + can be selected by this selector, as they expect.

Child-indexed Pseudo-classes

@@ -3897,6 +3908,13 @@ Appendix B: Obsolete but Required Parsing Quirks for Web Compat

Changes

+ Significant changes since the 2 February 2018 Working Draft: + + + Significant changes since the 2 May 2013 Working Draft include: