Re: Previous-sibling combinator

17.08.2012, 07:52, "Kang-Hao (Kenny) Lu" <kanghaol@oupeng.com>:
> (12/01/28 7:05), Marat Tanalin | tanalin.com wrote:
>
>> šThe "-" combinator is functionally similar to existing "+"
>> šcombinator, but selects previous-sibling element instead of
>> šnext-sibling one.
>>
>> šSo in result we would have "+" to move forward, and "-" to move
>> šbackward (like element.nextSibling and element.previousSibling in
>> šDOM, respectively).
>
> While I think this idea makes sense, using "-" would mean that you have
> to put spaces around "-". For example, compare
>
> ššx-element {} /* I am not following the Web Compoents work and I don't
> ššššššššššššššššššknow if the x-prefix idea is still there */
>
> to
>
> ššx - element {}
>
> .
>
> I have no idea how big this concern is.

I'm fine with making spaces around `-` combinator required (BTW currently I always put spaces around combinators for the purpose of readability).

Take into account though, that there is escaping feature in CSS. For example, in HTML5, identifiers are allowed to contain characters that are special in CSS. So to be used in selectors, such special characters must be escaped:

    <div id="lorem+ipsum"></div>

    #lorem\+ipsum {/**/}

There is nothing why `-` should be different, it just should be escaped if it has no special meaning in a specific place of selector:

    x\-element {/**/}

See also:
http://www.456bereastreet.com/archive/201011/html5_allows_almost_any_value_for_the_id_attribute_use_wisely/

Received on Friday, 17 August 2012 15:00:19 UTC