core: Misleading deprecation warning about "::v-deep", when ":deep" is used in a nested block with SASS

Version

3.2.19

Reproduction link

codesandbox.io

Steps to reproduce

  • Use Vue 3 with SFC and SASS
  • Use :deep inside 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

Most upvoted comments

The new syntax require using :deep (or ::v-deep) as a pseudo function - i.e. the parens are required:

:deep {} /* this is wrong */

:deep(div) {} /* this is correct */

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/replace

Find: ::v-deep (.*?) \{ Replace :deep($1) {

And for any that are strung together: Find: ::v-deep (.*?), Replace :deep($1),

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(…)

@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.

:deep() {
  .class {}
}

If you use less, you can nest styles in two ways.

// component style
@deep: ~':deep()';
@{deep} {
    .cls-1 {}
	.cls-2 {}
}

or

// vite.config.js
export default {
    css: {
        preprocessorOptions: {
            less: {
                modifyVars: {
                    'deep': ':deep()'
                }
            },
        },
    },
}

// component style
@{deep} {
    .cls-1 {}
	.cls-2 {}
}

We cleaned up all the ::v-deep occurrences in our code but I believe the warnings keep happening because third party libraries use still ::v-deep with the old syntax.

[@vue/compiler-sfc] ::v-deep usage as a combinator has been deprecated. Use :deep(<inner-selector>) instead.

::v-deep {
  .v-input--dense {}
  .v-skeleton-loader {}
}

I don’t understand how to use :deep() for above scenario.

can anyone help for the same?

https://github.com/vuejs/core/issues/4745#issuecomment-1254989020

Thank you, that was it!

instead of: ::v-deep.v-text-field .v-input__prepend-inner I 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-outer I 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 fieldset Solution 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)$2

And this one for multiple lines: FIND: ::v-deep((\s*\n\s*.+?)*)(\s*(\{|,)) REPLACE: :deep($1)$3

The new syntax require using :deep (or ::v-deep) as a pseudo function - i.e. the parens are required:

:deep {} /* this is wrong */

:deep(div) {} /* this is correct */

Without parens you are using it as a combinator, which is exactly what the message is warning you about.

vue3 没有根节点,如何用:deep(xxx)进行样式穿透?第一种可行,但会抛出警告,第二种没有效果

<template>
    <my-box-01></my-box-01>
    <my-box-02></my-box-02>
</template>

<style scoped lang="scss">
// 没有效果,这种该怎么写
:deep(.my-box-01) {
    background-color: red;
    .mb-text {
        color: green;
    }
}

</style>

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:

::v-deep.v-text-field.v-text-field--enclosed:not(.v-text-field--rounded)
  > .v-input__control
  > .v-input__slot {
  padding: 0 4px;
}

This was the result on the final code, it was overwriting vuetify class as it should: image

And when changed to

:deep(.v-text-field.v-text-field--enclosed:not(.v-text-field--rounded)
  > .v-input__control
  > .v-input__slot) {
  padding: 0 4px;
}```

The padding is not being overwritten anymore.

![image](https://user-images.githubusercontent.com/101707687/189876983-51694643-c0a7-46c5-a62c-f8098527b67e.png)

When I do as you suggested I get an error in the IDE image

[@vue/compiler-sfc] ::v-deep usage as a combinator has been deprecated. Use :deep(<inner-selector>) instead.

::v-deep {
  .v-input--dense {}
  .v-skeleton-loader {}
}

I don’t understand how to use :deep() for above scenario.

can anyone help for the same?

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.

  • This warning is really disturbing in console, just because it occurs too much.
  • I hope it’s displayed less time or removed at all as soon as possible.

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(…)

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 .class BUT then… how can I do ::v-deep.class (without spaces) with the new :deep() ?