W3C home > Mailing lists > Public > public-css-archive@w3.org > October 2017

Re: [csswg-drafts] [extend-rule]

From: Chris Eppstein via GitHub <sysbot+gh@w3.org>
Date: Mon, 09 Oct 2017 21:33:39 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-335296792-1507584804-sysbot+gh@w3.org>
The sass version of extend has a simple definition:

Given an expression `A { @extend B; }` where A is a complex selector and B is compound selector, style all elements matching `A` as if they have the element attributes implied by `B`.

In essence, this is a way of assigning HTML attributes with specific values to elements that do not have those traits such that selectors will match against them anyway for the purposes of styling them.

The placeholder selector has the semantics of the class attribute but for an attribute that does not exist in HTML. Because this "style placeholder" attribute can never be assigned from the document, it gives a CSS-only domain within which styles can be re-used without ever touching a html or templates.

A placeholder selector, like a class, can be used in any part of a complex selector, but those selectors never match an element unless they are extended, because there's no equivalent attribute in html for it.

The Sass implementation is problematic because it can only emulate this semantic through selector rewriting. In doing so, the specificity of the rewritten selector changes causing the selectors to match in a new overall cascade that is not the same as the original. But an in-browser implementation would not have this issue. As such, there's no reason to "instead treat the extend rule as plain simple substitution." It's is incorrect to even conceptualize `@extend` as a type of substitution or selector manipulation -- that is just how Sass attempts to *implement* it.

Of note: The legal syntax for the extended compound selector `B` referenced above would probably need to exclude certain attribute selector operators which do not resolve to a concrete attribute value -- The sass implementation does not do this because of the particulars of how it implements the concept of `@extend` does not force it to do so, but an in browser implementation would make sense to limit to just concrete html traits and not patterns of them.

GitHub Notification of comment by chriseppstein
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1855#issuecomment-335296792 using your GitHub account
Received on Monday, 9 October 2017 21:33:28 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:19 UTC