[Slash Separator] Selector functions throw errors for slash lists

Closes #2706
This commit is contained in:
Natalie Weizenbaum 2019-08-19 18:07:11 -07:00
parent 21560c910c
commit 871afdd863
3 changed files with 63 additions and 0 deletions

View File

@ -2,6 +2,9 @@
* Require at least two arguments for `slash-list()`.
* Require that selector functions throw errors when passed slash-separated
lists.
## Draft 1
* Initial draft.

View File

@ -22,6 +22,7 @@ operator.
* [`slash-list()` Function](#slash-list-function)
* [`rgb()` Function](#rgb-function)
* [`hsl()` Function](#hsl-function)
* [Selector Functions](#selector-functions)
* [Deprecation Process](#deprecation-process)
* [Phase 1](#phase-1)
* [Phase 2](#phase-2)
@ -348,6 +349,13 @@ overload to be the following:
* Otherwise, proceed with the existing definition of the function.
### Selector Functions
This proposal modifies [the "Parse a Selector From a SassScript Object"
procedure][] to throw an error whenever it encounters a slash-separated list.
[the "Parse a Selector From a SassScript Object" procedure]: ../spec/functions/selector.md#parse-a-selector-from-a-sassscript-object
## Deprecation Process
The deprecation process will be divided into three phases:

View File

@ -0,0 +1,52 @@
# Selector Functions
## Table of Contents
* [Procedures](#procedures)
* [Parse a Selector From a SassScript Object](#parse-a-selector-from-a-sassscript-object)
## Procedures
### Parse a Selector From a SassScript Object
This algorithm takes a SassScript object `selector` and returns an abstract
representation of a CSS selector.
* Set `text` to an empty string.
* If `selector` is a list:
* If `selector` is bracketed, throw an error.
* If `selector` is space-separated:
* If `selector` contains any non-string elements, throw an error.
* Set `text` to the concatenation of each element of `selector`, separated
by spaces.
* Otherwise, if `selector` is comma-separated:
* For each element `complex` of `selector`:
* If `complex` is a list:
* If `complex` is bracketed or comma-separated, throw an error.
* Otherwise, if `complex` contains any non-string elements, throw an error.
* Otherwise, append the concatenation of each element of `selector`, separated
by spaces, to `text`.
* Otherwise, if `complex` is not a string, throw an error.
* Otherwise, append `complex` to text.
* Append a comma to `text` unless `complex` is the last element of
`selector`.
* Otherwise, if `selector` is not a string, throw an error.
* Otherwise, set `text` to the contents of `selector`.
* Parse `text` as a selector and return the result.