Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip newlines when parsing selectors #13280

Merged
merged 2 commits into from
Mar 19, 2024
Merged

Conversation

RobinMalfait
Copy link
Member

@RobinMalfait RobinMalfait commented Mar 19, 2024

This PR introduces a small improvement when parsing CSS where selectors including newlines (\n) are replaced with a space.

This means that the preflight in Tailwind Play looked like this:

/*! tailwindcss v4.0.0-alpha.9 | MIT License | https://tailwindcss.com */
@layer base {
  *,
::after,
::before,
::backdrop,
::first-letter,
::file-selector-button {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    border: 0 solid;
  }
  html,
:host {
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    tab-size: 4;
    font-family: var( --default-font-family, ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji' );
    font-feature-settings: var(--default-font-feature-settings, normal);
    font-variation-settings: var(--default-font-variation-settings, normal);
    -webkit-tap-highlight-color: transparent;
  }
  body {
    line-height: inherit;
  }
  hr {
    height: 0;
    color: inherit;
    border-top-width: 1px;
  }
  abbr:where([title]) {
    -webkit-text-decoration: underline dotted;
    text-decoration: underline dotted;
  }
  h1,
h2,
h3,
h4,
h5,
h6 {
    font-size: inherit;
    font-weight: inherit;
  }
  a {
    color: inherit;
    -webkit-text-decoration: inherit;
    text-decoration: inherit;
  }
  b,
strong {
    font-weight: bolder;
  }
  code,
kbd,
samp,
pre {
    font-family: var( --default-mono-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace );
    font-feature-settings: var(--default-mono-font-feature-settings, normal);
    font-variation-settings: var(--default-mono-font-variation-settings, normal);
    font-size: 1em;
  }
  small {
    font-size: 80%;
  }
  sub,
sup {
    font-size: 75%;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
  }
  sub {
    bottom: -0.25em;
  }
  sup {
    top: -0.5em;
  }
  table {
    text-indent: 0;
    border-color: inherit;
    border-collapse: collapse;
  }
  button,
input,
optgroup,
select,
textarea,
::file-selector-button {
    font: inherit;
    font-feature-settings: inherit;
    font-variation-settings: inherit;
    color: inherit;
    background: transparent;
  }
  input:where(:not([type='button'], [type='reset'], [type='submit'])),
select,
textarea {
    border: 1px solid;
  }
  button,
input:where([type='button'], [type='reset'], [type='submit']),
::file-selector-button {
    appearance: button;
  }
  :-moz-focusring {
    outline: auto;
  }
  :-moz-ui-invalid {
    box-shadow: none;
  }
  progress {
    vertical-align: baseline;
  }
  ::-webkit-inner-spin-button,
::-webkit-outer-spin-button {
    height: auto;
  }
  ::-webkit-search-decoration {
    -webkit-appearance: none;
  }
  summary {
    display: list-item;
  }
  ol,
ul,
menu {
    list-style: none;
  }
  textarea {
    resize: vertical;
  }
  ::placeholder {
    opacity: 1;
    color: color-mix(in srgb, currentColor 50%, transparent);
  }
  :disabled {
    cursor: default;
  }
  img,
svg,
video,
canvas,
audio,
iframe,
embed,
object {
    display: block;
    vertical-align: middle;
  }
  img,
video {
    max-width: 100%;
    height: auto;
  }
  [hidden] {
    display: none!important;
  }
}

Now looks like this:

/*! tailwindcss v4.0.0-alpha.9 | MIT License | https://tailwindcss.com */
@layer base {
  *, ::after, ::before, ::backdrop, ::first-letter, ::file-selector-button {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    border: 0 solid;
  }
  html, :host {
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    tab-size: 4;
    font-family: var( --default-font-family, ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji' );
    font-feature-settings: var(--default-font-feature-settings, normal);
    font-variation-settings: var(--default-font-variation-settings, normal);
    -webkit-tap-highlight-color: transparent;
  }
  body {
    line-height: inherit;
  }
  hr {
    height: 0;
    color: inherit;
    border-top-width: 1px;
  }
  abbr:where([title]) {
    -webkit-text-decoration: underline dotted;
    text-decoration: underline dotted;
  }
  h1, h2, h3, h4, h5, h6 {
    font-size: inherit;
    font-weight: inherit;
  }
  a {
    color: inherit;
    -webkit-text-decoration: inherit;
    text-decoration: inherit;
  }
  b, strong {
    font-weight: bolder;
  }
  code, kbd, samp, pre {
    font-family: var( --default-mono-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace );
    font-feature-settings: var(--default-mono-font-feature-settings, normal);
    font-variation-settings: var(--default-mono-font-variation-settings, normal);
    font-size: 1em;
  }
  small {
    font-size: 80%;
  }
  sub, sup {
    font-size: 75%;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
  }
  sub {
    bottom: -0.25em;
  }
  sup {
    top: -0.5em;
  }
  table {
    text-indent: 0;
    border-color: inherit;
    border-collapse: collapse;
  }
  button, input, optgroup, select, textarea, ::file-selector-button {
    font: inherit;
    font-feature-settings: inherit;
    font-variation-settings: inherit;
    color: inherit;
    background: transparent;
  }
  input:where(:not([type='button'], [type='reset'], [type='submit'])), select, textarea {
    border: 1px solid;
  }
  button, input:where([type='button'], [type='reset'], [type='submit']), ::file-selector-button {
    appearance: button;
  }
  :-moz-focusring {
    outline: auto;
  }
  :-moz-ui-invalid {
    box-shadow: none;
  }
  progress {
    vertical-align: baseline;
  }
  ::-webkit-inner-spin-button, ::-webkit-outer-spin-button {
    height: auto;
  }
  ::-webkit-search-decoration {
    -webkit-appearance: none;
  }
  summary {
    display: list-item;
  }
  ol, ul, menu {
    list-style: none;
  }
  textarea {
    resize: vertical;
  }
  ::placeholder {
    opacity: 1;
    color: color-mix(in srgb, currentColor 50%, transparent);
  }
  :disabled {
    cursor: default;
  }
  img, svg, video, canvas, audio, iframe, embed, object {
    display: block;
    vertical-align: middle;
  }
  img, video {
    max-width: 100%;
    height: auto;
  }
  [hidden] {
    display: none!important;
  }
}

@RobinMalfait RobinMalfait force-pushed the feat/improve-parsing-selectors branch from fc24aad to 7c278f0 Compare March 19, 2024 15:16
@RobinMalfait RobinMalfait merged commit d2be632 into next Mar 19, 2024
1 check passed
@RobinMalfait RobinMalfait deleted the feat/improve-parsing-selectors branch March 19, 2024 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants