core: Misleading deprecation warning about "::v-deep", when ":deep" is used in a nested block with SASS
Version
3.2.19
Reproduction link
Steps to reproduce
- Use Vue 3 with SFC and SASS
- Use
:deepinside a nested block
<style scoped lang="scss">
:deep {
// more rules
}
:deep() {
// more rules
}
</style>
What is expected?
A clear definition in the manual, what is the correct way to do this.
I would expect the first syntax to work at least. For the second syntax I would either expect the same, or a fitting error message, telling me, that this is not allowed.
What is actually happening?
https://v3.vuejs.org/api/sfc-style.html#style-scoped only has an easy example .a :deep(.b), but no nesting together with SASS.
The first syntax works, but brings up a misleading warn message
[@vue/compiler-sfc] ::v-deep usage as a combinator has been deprecated. Use ::v-deep(<inner-selector>) instead.
I do not use the (legacy) ::v-deep, but moved to the (new Vue3) :deep.
The second syntax works as intended without any warning. However I am not sure, if this is intended by Vue.
Being not so deep into Vue and its modules and dependencies, I am not sure, whether this is a SASS thing, a Vue thing or whether you two have to figure this out together.
I just lost a few hours searching for an incompatible library, just ending up finding it’s still a component of mine and the deprecation message mislead me totally. Hope, this bug report helps others 😃
I read and understood, that you don’t want to answer questions, but I think the question, whether :deep() { ... } is the right way to go, should be answered (and put into the manual). Thank you! 😃
Affected version: I noticed it after upgrading from Vue 2 to 3.1.0, but the issue is also reproducible with latest 3.2.19 (see sandbox)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 28 (1 by maintainers)
Commits related to this issue
- MXS-4235 Replace the usage of `::v-deep` selector` in Query Editor MaxGUI uses mocha as the test runner. But Vue 2.7 doesn't work well with `@vue/cli-plugin-unit-mocha` at the moment so all unit test... — committed to mariadb-corporation/MaxScale by mariadb-ThienLy 2 years ago
- MXS-4234 Replace deprecated `::v-deep` with `:deep()` https://github.com/vuejs/core/issues/4745#issuecomment-937370398 — committed to mariadb-corporation/MaxScale by mariadb-ThienLy 2 years ago
- MXS-4234 Replace deprecated `::v-deep` with `:deep()` https://github.com/vuejs/core/issues/4745#issuecomment-937370398 — committed to mariadb-corporation/MaxScale by mariadb-ThienLy 2 years ago
The new syntax require using
:deep(or::v-deep) as a pseudo function - i.e. the parens are required:Without parens you are using it as a combinator, which is exactly what the message is warning you about.
Is there any way to disable the warning? We are upgrading an exiting project from Vue 2x to Vue 3. Due to technical reasons out of scope to explain here, we have +12000 lines of scss nested under a single ::v-deep { … }. It’s not an alternative for us to wrap every single class in a :deep(…)
Maybe this will help someone resolve this issue in larger code bases. We made the changes above to use
:deep() { ... }and did so using regex find/replaceFind:
::v-deep (.*?) \{Replace:deep($1) {And for any that are strung together: Find:
::v-deep (.*?),Replace:deep($1),@yyx990803 we would appreciate a solution to this, we’re working with a 200 component Nuxt app and our DX is ruined by the flood of warnings. We don’t wanna be warned.
@webturtles18 The following worked, but I am not sure if it is the intended use, as @theHacker says.
If you use
less, you can nest styles in two ways.or
We cleaned up all the
::v-deepoccurrences in our code but I believe the warnings keep happening because third party libraries use still::v-deepwith the old syntax.[@vue/compiler-sfc] ::v-deep usage as a combinator has been deprecated. Use :deep(<inner-selector>) instead.I don’t understand how to use :deep() for above scenario.
can anyone help for the same?
vue2 fixed: v2.7.11 https://github.com/vuejs/vue/releases/tag/v2.7.11 https://github.com/vuejs/vue/commit/2f335b2f9d09b962f40e38740826d444e4fff073
https://github.com/vuejs/core/issues/4745#issuecomment-1254989020
Thank you, that was it!
instead of:
::v-deep.v-text-field .v-input__prepend-innerI used:.v-text-field :deep(.v-input__prepend-inner)in a case more complicated, instead of:
::v-deep.v-text-field--full-width.v-input--dense:not(.v-text-field--solo).v-text-field--outlined .v-input__prepend-outerI used:.v-text-field--full-width.v-input--dense:not(.v-text-field--solo).v-text-field--outlined :deep(.v-input__prepend-outer)And if we’ve something as:
::v-deep.v-text-field.v-text-field--enclosed:not(.v-text-field--rounded) > .v-input__control > .v-input__slot:hover fieldsetSolution would be:.v-text-field.v-text-field--enclosed:not(.v-text-field--rounded) > :deep(.v-input__control > .v-input__slot:hover fieldset)Hope it helps others
https://github.com/vuejs/core/issues/4745#issuecomment-1256583705
About the regex, I recommend those instead:
This one will do the same as both on comment above: FIND:
::v-deep (.+?)(\s?(\{|,))REPLACE::deep($1)$2And this one for multiple lines: FIND:
::v-deep((\s*\n\s*.+?)*)(\s*(\{|,))REPLACE::deep($1)$3vue3 没有根节点,如何用:deep(xxx)进行样式穿透?第一种可行,但会抛出警告,第二种没有效果
I was able to migrate all to :deep, but I’ve found out that the style is not the same anymore. It doesn’t overwrite the css classes.
I am using vue 2 (2.7.10) + nuxt(2.15.8) + vuetify(2.6.10)
I was changing one component that only have this simple css line:
This was the result on the final code, it was overwriting vuetify class as it should:
And when changed to
When I do as you suggested I get an error in the IDE
hi, do you find any solutions for this?
A solution is kindly needed for this. Warnings keeps coming up even after removing all ::v-deep occurrences from the code.
A helpful feature is to add a file path or code reference for where the warning is being triggered. This will surely help locating the issue and fix it.
@yyx990803
WARN [@vue/compiler-sfc] ::v-deep usage as a combinator has been deprecated. Use :deep(<inner-selector>) instead.As @adamxi remarked, this feature is expected to come soon. If this is possible, it’s not a problem that above warning is shown.
So, I discover that
:deep(.class)works the same as::v-deep .classBUT then… how can I do::v-deep.class(without spaces) with the new :deep() ?