-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
fix(compiler-sfc): Show location of >>> / /deep/ in the ...combinators have been deprecated message #8596
base: main
Are you sure you want to change the base?
fix(compiler-sfc): Show location of >>> / /deep/ in the ...combinators have been deprecated message #8596
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -4,15 +4,18 @@ import { warn } from '../warn' | |||||||||
|
||||||||||
const animationNameRE = /^(-\w+-)?animation-name$/ | ||||||||||
const animationRE = /^(-\w+-)?animation$/ | ||||||||||
type pluginParam = { id: string; filename?: string } | ||||||||||
|
||||||||||
const scopedPlugin: PluginCreator<string> = (id = '') => { | ||||||||||
const scopedPlugin: PluginCreator<pluginParam> = ( | ||||||||||
params: pluginParam | undefined | ||||||||||
) => { | ||||||||||
const keyframes = Object.create(null) | ||||||||||
const shortId = id.replace(/^data-v-/, '') | ||||||||||
const shortId = params!.id.replace(/^data-v-/, '') | ||||||||||
|
||||||||||
return { | ||||||||||
postcssPlugin: 'vue-sfc-scoped', | ||||||||||
Rule(rule) { | ||||||||||
processRule(id, rule) | ||||||||||
processRule(params!.id, rule, params!.filename) | ||||||||||
}, | ||||||||||
AtRule(node) { | ||||||||||
if ( | ||||||||||
|
@@ -61,7 +64,7 @@ const scopedPlugin: PluginCreator<string> = (id = '') => { | |||||||||
|
||||||||||
const processedRules = new WeakSet<Rule>() | ||||||||||
|
||||||||||
function processRule(id: string, rule: Rule) { | ||||||||||
function processRule(id: string, rule: Rule, filename = '') { | ||||||||||
if ( | ||||||||||
processedRules.has(rule) || | ||||||||||
(rule.parent && | ||||||||||
|
@@ -73,7 +76,7 @@ function processRule(id: string, rule: Rule) { | |||||||||
processedRules.add(rule) | ||||||||||
rule.selector = selectorParser(selectorRoot => { | ||||||||||
selectorRoot.each(selector => { | ||||||||||
rewriteSelector(id, selector, selectorRoot) | ||||||||||
rewriteSelector(id, selector, selectorRoot, filename) | ||||||||||
}) | ||||||||||
}).processSync(rule.selector) | ||||||||||
} | ||||||||||
|
@@ -82,22 +85,24 @@ function rewriteSelector( | |||||||||
id: string, | ||||||||||
selector: selectorParser.Selector, | ||||||||||
selectorRoot: selectorParser.Root, | ||||||||||
filename = '', | ||||||||||
slotted = false | ||||||||||
) { | ||||||||||
let node: selectorParser.Node | null = null | ||||||||||
let shouldInject = true | ||||||||||
// find the last child node to insert attribute selector | ||||||||||
selector.each(n => { | ||||||||||
// DEPRECATED ">>>" and "/deep/" combinator | ||||||||||
|
||||||||||
if ( | ||||||||||
n.type === 'combinator' && | ||||||||||
(n.value === '>>>' || n.value === '/deep/') | ||||||||||
) { | ||||||||||
n.value = ' ' | ||||||||||
n.spaces.before = n.spaces.after = '' | ||||||||||
warn( | ||||||||||
`the >>> and /deep/ combinators have been deprecated. ` + | ||||||||||
`Use :deep() instead.` | ||||||||||
`the >>> and /deep/ combinators have been deprecated. ` + | ||||||||||
`Use :deep() instead.(${filename}(${n.source?.start?.line} : ${n.source?.start?.column}))` | ||||||||||
Comment on lines
+104
to
+105
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The spacing of this message seems a bit off, as does the nested bracketing. I also wonder whether the column is really that useful in this context. Perhaps something like this instead?
Suggested change
|
||||||||||
) | ||||||||||
return false | ||||||||||
} | ||||||||||
|
@@ -131,7 +136,7 @@ function rewriteSelector( | |||||||||
// .foo ::v-deep .bar -> .foo[xxxxxxx] .bar | ||||||||||
warn( | ||||||||||
`${value} usage as a combinator has been deprecated. ` + | ||||||||||
`Use :deep(<inner-selector>) instead of ${value} <inner-selector>.` | ||||||||||
`Use :deep(<inner-selector>) instead of ${value} <inner-selector>.(${filename}(${n.source?.start?.line} : ${n.source?.start?.column}))` | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the other message, perhaps something like this?
Suggested change
|
||||||||||
) | ||||||||||
|
||||||||||
const prev = selector.at(selector.index(n) - 1) | ||||||||||
|
@@ -147,7 +152,13 @@ function rewriteSelector( | |||||||||
// instead. | ||||||||||
// ::v-slotted(.foo) -> .foo[xxxxxxx-s] | ||||||||||
if (value === ':slotted' || value === '::v-slotted') { | ||||||||||
rewriteSelector(id, n.nodes[0], selectorRoot, true /* slotted */) | ||||||||||
rewriteSelector( | ||||||||||
id, | ||||||||||
n.nodes[0], | ||||||||||
selectorRoot, | ||||||||||
filename, | ||||||||||
true /* slotted */ | ||||||||||
) | ||||||||||
let last: selectorParser.Selector['nodes'][0] = n | ||||||||||
n.nodes[0].each(ss => { | ||||||||||
selector.insertAfter(last, ss) | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type names usually begin with uppercase letters.