Re: Domain selectors

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 22:29:51 UTC