tailwindcss/__tests__
Adam Wathan 007231fbfc Require plugin authors to manually escape variants
Not 100% convinced this is a net positive change, but I regret not having done things this way at the beginning.

In 0.x, we pass the `separator` and `className` values already escaped, so `:` comes through as `\:` for example, and `w-1/2` comes through as `w-1\/2`.

At first this sounds fine, less work for the plugin author right? But CSS escaping rules are kind of complicated and you have to escape characters differently depending on whether or not they are at the start of an identifier.

For example, it's totally fine for a class to contain a zero (`0` ), but it can't _start_ with a zero. For a class to start with a zero, it needs to be escaped like this: `\30 `

This means that as a general rule, trying to escape the individual segments of a class separately is a bad idea — you should escape the class as a whole so only the necessary escaping is applied. We break this rule when we pre-escape the separator and className for plugin authors who use the `modifySelectors` function.

We already require users to manually escape class names when they are using `addUtilities` or `addComponents`, so to me it feels more consistent for things to work this way and it's how they should have worked from day one.

Basically this code:

```js
function({ addVariant }) {
  addVariant('first-child', ({ modifySelectors, separator }) => {
    modifySelectors(({ className }) => {
      return `.first-child${separator}${className}:first-child`
    })
  })
},
```

...would need to be re-written like this if I merge this change:

```js
function({ addVariant, e }) {
  addVariant('first-child', ({ modifySelectors, separator }) => {
    modifySelectors(({ className }) => {
      return `.${e(`first-child${separator}${className}`)}:first-child`
    })
  })
},
```

Although I think this is the right way for this to work, I hesitate because it's a breaking change that makes any variant plugins authored for 0.x incompatible with 1.x. It's an easy fix on the plugin author's part, but it's still annoying.

I'm leaning towards merging so I don't regret this even more later when the plugin ecosystem is a lot bigger. Anyone have any thoughts?
2019-02-28 10:17:09 -05:00
..
fixtures Split flexShrink to separate plugin 2019-02-26 10:33:34 -05:00
applyAtRule.test.js Extract padding/margin values to spacing 2019-02-16 20:33:05 -05:00
cli.compile.test.js Refactored the CLI build process to use configuration object instead of many arguments. 2019-02-04 21:42:27 -06:00
cli.test.js Don't skip CLI tests 2019-02-01 12:32:50 -05:00
cli.utils.test.js Refactored the CLI build process to use configuration object instead of many arguments. 2019-02-04 21:42:27 -06:00
configFunction.test.js Move colors inside of theme 2019-02-01 12:32:50 -05:00
configurePlugins.test.js Fix code style 2019-02-05 13:37:05 -05:00
containerPlugin.test.js Move screens into theme config 2019-02-01 12:32:50 -05:00
customConfig.test.js Move screens into theme config 2019-02-01 12:32:50 -05:00
defaultConfig.test.js Rename test to be more clear 2017-11-24 14:14:04 -05:00
escapeClassName.test.js Switch to more robust existing CSS escaping library 2018-06-04 09:14:38 -04:00
parseObjectStyles.test.js Get object style parsing working without the insanity 2018-03-07 09:37:01 -05:00
prefixSelector.test.js Remove prefixTree, update relevant tests 2019-01-14 15:43:12 -05:00
processPlugins.test.js Fix undefined var in one test 2019-02-22 16:59:56 +01:00
resolveConfig.test.js Fix code style 2019-02-14 07:48:57 -05:00
responsiveAtRule.test.js Finish merge of master 2019-02-07 13:58:47 -05:00
sanity.test.js Move important to top level option 2019-02-01 12:32:50 -05:00
variantsAtRule.test.js Require plugin authors to manually escape variants 2019-02-28 10:17:09 -05:00