Skip to content

fix(compiler-sfc): scoped style leak when using pseudo classes (fix #8868) #9693

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

Conversation

kleinfreund
Copy link
Contributor

@kleinfreund kleinfreund commented Nov 28, 2023

Fix a scoped style leak when using pseudo classes caused by the scoped style attribute (i.e. [data-v-...]) not being attached to the key part of a selector when it contains pseudo class selectors.

Closes #8868.


Note that the PR in its current state changes the placement of the scoped style attribute when using pseudo classes from "inject before the pseudo class selector" to "inject after the pseudo class selector" (e.g. [data-v-test]::selection becomes ::selection[data-v-test]). Both should be functionally/semantically equivalent, but they do look a little strange. Especially for functional style pseudo classes, this looks weird: input:not(.error)[data-v-test].

Changing the logic in pluginScoped to inject the scoped style attribute to always be at the start of pseudo class selectors in key position would definitely increase the complexity of the code here. Let me know if the PR’s current behavior is a problem and should be changed.

Just to be clear, I think the position of the scoped style attribute is pretty much just a cosmetic issue as far as I can tell.

Copy link

github-actions bot commented Nov 28, 2023

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 89.4 kB 34 kB 30.7 kB
vue.global.prod.js 146 kB 53.3 kB 47.5 kB

Usages

Name Size Gzip Brotli
createApp 49.8 kB 19.5 kB 17.8 kB
createSSRApp 53.1 kB 20.8 kB 19 kB
defineCustomElement 52 kB 20.2 kB 18.5 kB
overall 63.2 kB 24.4 kB 22.2 kB

@kleinfreund kleinfreund marked this pull request as ready for review November 28, 2023 09:53
@kleinfreund kleinfreund force-pushed the fix/scoped-style-leak-when-using-pseudo-classes branch from 36816bd to e3f3360 Compare December 4, 2023 13:56
Fix a scoped style leak when using pseudo classes caused by the scoped style attribute (i.e. `[data-v-...]`) not being attached to the key part of a selector when it contains pseudo class selectors.

Closes vuejs#8868.
@kleinfreund kleinfreund force-pushed the fix/scoped-style-leak-when-using-pseudo-classes branch from e3f3360 to 4332072 Compare January 3, 2024 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Rejected
Development

Successfully merging this pull request may close these issues.

Scoped style attribute not attached to selector key if it's a pseudo-class/element
2 participants