Re: [css-selectors] Empty input selector

fantasai:
> On 04/20/2011 01:00 PM, Rudolph Gottesheim wrote:
>> input[value=''] { background-color:#f00; }
>> <input value="" />
>> 
>> Why doesn't the second input turn red when you enter something?
> 
> the [value] selector selects on the DOM.

> I'll add it to the list of things to consider for Selectors 4.

<http://wiki.csswg.org/spec/selectors4>
<http://dev.w3.org/csswg/selectors4/>

I would group it with (proposed) pseudo-attribute selectors

  input[:value=''] {foo: bar}
  input[#value=''] {foo: bar}
  input[@value=''] {foo: bar}

since it should neither be a pseudo-class selector

  input:value('')   {foo: bar}
  input:empty-value {foo: bar}

nor a pseudo-element selector

  input::value('')   {foo: bar}
  input::empty-value {foo: bar}

and would be more flexible this way.

By the way, for matching of attribute values we currently have:

   ‘=’ (exact)
  ‘~=’ (in list)
  ‘|=’ (exact or starts with followed by dash anything)
  ‘^=’ (starts with)
  ‘$=’ (ends with)
  ‘*=’ (contains) 

Although there is ‘:not()’, I think it would be nice to have negated comparisons, i.e. at least
 
  ‘!=’ 

but possibly also the rest

  ‘!~=’ 
  ‘!|=’ 
  ‘!^=’ 
  ‘!$=’
  ‘!*=’

On the list of ideas we already find numeric attribute selectors

  ‘<=’ = ‘!>’
  ‘<’  = ‘!>=’
  ‘>=’ = ‘!<’
  ‘>’  = ‘!<=’

but only for lager and smaller comparisons. We additionally may want numeric equality comparison where ‘0’ = ‘0.0’ = ‘.0’ = ‘00’ = ‘’:

  ‘#=’

A binary logic attribute selector could handle ‘yes’ = ‘true’ = ‘1’ = ‘on’ = attribute-name, possibly depending on the markup language:

  ‘?=’
  ‘!?=’

An assertion attribute selector could be used to test whether a value would be legal (without applying it):

  ‘:=’
  ‘!:=’

The colon, though, might be more appropriate for attribute sub-values, e.g. “[color:red>50%]” or “[href:protocol!=http]”.

We may also want more intelligent, typed numeric attribute selectors that take (CSS) (length) units into account, e.g. ‘25.4mm’ = ‘1in’ = ‘72pt’ or ‘#FF0000’ = ‘red’.

  ‘_=’
  ‘_<=’, ‘_<’
  ‘_>=’, ‘_>’

They could also apply numeric values to a percentage scale, i.e ‘.5’ = ‘0.50’ = ‘50%’:

  ‘%=’
  ‘%<=’, ‘%<’
  ‘%>=’, ‘%>’

Someone else may also find uses for

  ‘+=’
  ‘-=’
  ‘&=’
  ‘@=’
  ‘`=’
  ‘/=’
  ‘,=’
  ‘;=’
  ‘.=’

for example for case (in)sensitive string comparison. I’m not sure whether

  ‘==’

could be used for that, i.e. whether today ‘[foo==]’ should match ‘<bar foo="="/>’.

Received on Friday, 29 April 2011 09:54:08 UTC