Re: Domain selectors

> 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