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

[Bug]: reduceInitial ignore pointer-events not working #1436

Closed
jamacoe opened this issue Oct 8, 2022 · 9 comments · Fixed by #1482
Closed

[Bug]: reduceInitial ignore pointer-events not working #1436

jamacoe opened this issue Oct 8, 2022 · 9 comments · Fixed by #1482
Labels
Milestone

Comments

@jamacoe
Copy link

jamacoe commented Oct 8, 2022

Describe the bug

In gulp 4: disabling reduceInitial from default preset work, so obv. I'm addressing the thing correct. But { ignore : ["pointer-events"] } doesn't have any effect on the output. pointer-events: initial will be translated to pointer-events: auto.

...
.pipe(postcss([ cssnano({
        preset: ['default', { 
               // reduceInitial: false
               reduceInitial: { ignore : ["pointer-events"] }
        }]
}) ]))
...

Expected behaviour

I expect pointer-events: initial to be left untouched.

Steps to reproduce

CSS:

.test {
pointer-events: initial;
}

Version

5.1.13

Preset

default

Environment

System:
    OS: Windows 10 10.0.19044
    CPU: (16) x64 AMD Ryzen 7 4800H with Radeon Graphics
    Memory: 53.05 GB / 63.42 GB

Package details

+-- autoprefixer@10.4.12
| `-- postcss@8.4.17
+-- cssnano@5.1.13
| +-- cssnano-preset-default@5.2.12
| | +-- css-declaration-sorter@6.3.1
| | | `-- postcss@8.4.17 deduped
| | +-- cssnano-utils@3.1.0
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-calc@8.2.4
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-colormin@5.3.0
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-convert-values@5.1.2
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-discard-comments@5.1.2
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-discard-duplicates@5.1.0
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-discard-empty@5.1.1
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-discard-overridden@5.1.0
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-merge-longhand@5.1.6
| | | +-- postcss@8.4.17 deduped
| | | `-- stylehacks@5.1.0
| | |   `-- postcss@8.4.17 deduped
| | +-- postcss-merge-rules@5.1.2
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-minify-font-values@5.1.0
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-minify-gradients@5.1.1
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-minify-params@5.1.3
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-minify-selectors@5.2.1
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-normalize-charset@5.1.0
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-normalize-display-values@5.1.0
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-normalize-positions@5.1.1
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-normalize-repeat-style@5.1.1
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-normalize-string@5.1.0
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-normalize-timing-functions@5.1.0
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-normalize-unicode@5.1.0
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-normalize-url@5.1.0
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-normalize-whitespace@5.1.1
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-ordered-values@5.1.3
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-reduce-initial@5.1.0
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-reduce-transforms@5.1.0
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-svgo@5.1.0
| | | `-- postcss@8.4.17 deduped
| | +-- postcss-unique-selectors@5.1.1
| | | `-- postcss@8.4.17 deduped
| | `-- postcss@8.4.17 deduped
| `-- postcss@8.4.17 deduped
`-- gulp-postcss@9.0.1
  +-- postcss-load-config@3.1.4
  | `-- postcss@8.4.17 deduped
  `-- postcss@8.4.17 deduped

Additional context

No response

@ludofischer
Copy link
Collaborator

Thank you for the bug report. What you are trying to do seems reasonable, but I think at the moment cssnano ignores any plugin options except false or ignore when the plugin is part of a preset. I think it is a mistake in the configuration loading code.

@alexander-akait
Copy link
Member

@jamacoe Why you want to disable it?

@jamacoe
Copy link
Author

jamacoe commented Oct 25, 2022

@alexander-akait I try to get rid of warnings reported by CSS validator. It reports:
"auto is not defined by any specification as an allowed value for pointer-events, but is supported in multiple browsers"
So I set it to 'initial' but cssnano will change it to 'auto', because that's shorter.

@alexander-akait
Copy link
Member

@jamacoe Can you provide the source code of this warning? Thank you

@jamacoe
Copy link
Author

jamacoe commented Oct 25, 2022

@alexander-akait

Complete .css source to reproduce:
.test{pointer-events:initial}

cssnano compiles this to:
.test{pointer-events:auto}

Enter it interactivly at https://jigsaw.w3.org/css-validator/#validate_by_input+with_options and receive warning:
auto is not defined by any specification as an allowed value for pointer-events, but is supported in multiple browsers

@alexander-akait
Copy link
Member

I see, thank you

@ludofischer
Copy link
Collaborator

The validator might be wrong, pointer-events: auto is defined in the specification: https://svgwg.org/svg2-draft/interact.html#PointerEventsProperty

@ludofischer ludofischer added this to the 6.0.0 milestone Nov 20, 2022
@ludofischer ludofischer modified the milestones: 6.0.0, backlog Mar 12, 2023
@ludofischer ludofischer modified the milestones: backlog, 6.0.0 Mar 22, 2023
@ludofischer
Copy link
Collaborator

Possible duplicate of #663 (plugin options have no effect when the plugin config is nested inside a preset config)

@ludofischer
Copy link
Collaborator

Actually the issue is specific to the way pointer-events is configured, it tries to read its options in the prepare() phase of the plugin lifecycle bu this does not work when the plugin is istantiated by cssnano.

ludofischer added a commit that referenced this issue Mar 22, 2023
Fix #1436

Ensure options are read also when the plugin is configured
in cssnano instead as a standalone PostCSS plugin.
ludofischer added a commit that referenced this issue Mar 23, 2023
Fix #1436

Ensure options are read also when the plugin is configured
in cssnano instead as a standalone PostCSS plugin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants