W3C home > Mailing lists > Public > www-style@w3.org > March 2015

Re: Domain selectors

From: Jonathan Kingston <jonathan@jooped.co.uk>
Date: Sun, 8 Mar 2015 23:08:21 +0000
Message-ID: <CA+EVJMXVMkVMg7+7=nZCFCQpwv9eC9=YOfYRQ9Pi8U-+JOrbYA@mail.gmail.com>
To: Marat Tanalin <mtanalin@yandex.ru>
Cc: Jens Oliver Meiert <jens@meiert.com>, "L. David Baron" <dbaron@dbaron.org>, W3C WWW Style <www-style@w3.org>
> On scanning I wonder whether @document isn’t rather complicated, and
> would deem the @-rule format a bigger issue than the likely repetition
> of selectors as proposed with [host=]. @document doesn’t seem to be
> much of an advantage over just using a separate style sheet, an option
> always at our disposal, whereas [host=], as a selector, would allow
> for easy, DRY domain-specific adjustments.

Surely a more specific selector would increase the need for repetition, can
you expand on the meaning?

I'm not really sure on the use-case here much as the following code:

my-component {
  color: red !important;
}
@document domain('domain.com') {
  my-component {
    color: blue;
  }
}

The color would still be red.

The only use-case I can see it being used for is having code similar to
this:

my-component {
  color: red;
}
@document domain('domain.com') {
  my-component {
    color: blue;
  }
}
@document domain('other-domain.com') {
  my-component {
    color: yellow;
  }
}

Then using a minifier to compile the code for other-domain down to:
my-component {
  color: yellow;
}

However users who using development build tools for CSS are likely not to
need this.

On 8 March 2015 at 22:28, Marat Tanalin <mtanalin@yandex.ru> wrote:

> 09.03.2015, 01:02, "Jens Oliver Meiert" <jens@meiert.com>:
> > @document doesn’t seem to be
> > much of an advantage over just using a separate style sheet, an option
> > always at our disposal, whereas [host=], as a selector, would allow
> > for easy, DRY domain-specific adjustments.
>
> `[host="example.com"]` selects elements that have `host` attribute with `
> example.com` as its value.
>
> As an alternative selector syntax for your purpose, a function could be
> used instead of the attribute-selector syntax you've proposed:
>
>     ::domain("example.com") .foo {
>         /* Domain-specific styles for elements
>            with the `foo` class. */
>     }
>
> But this does not seem to have serious advantages (other than just
> somewhat simpler syntax thanks to less braces) over an at-rule like
> `@document`:
>
>     @document domain("example.com") {
>         .foo {
>             /* Domain-specific styles for elements
>                with the `foo` class. */
>         }
>     }
>
> Possible drawbacks of the `@document` at-rule in its current form are:
>
>     * `@document domain("example.com")` selects not just `example.com`,
>       but also its subdomains like `bar.example.com`. There should
>       probably a way to select exact domains, e.g. `example.com` only,
>       without its subdomains;
>
>     * there is the `regexp()` function that may be considered
>       "too complicated" or "too slow" by some people (not really an issue,
>       but could easily be postponed to a next spec level).
>
> Some people also mention some security issues, but it's unclear what exact
> issues they mean.
>
>
Received on Sunday, 8 March 2015 23:08:49 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:30 UTC