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

fix(compiler-sfc): ignore style comment in transform stage #6808

Merged
merged 6 commits into from
Nov 8, 2022

Conversation

rudyxu1102
Copy link
Contributor

@rudyxu1102 rudyxu1102 commented Oct 2, 2022

Fix #6807

@zhangzhonghe
Copy link
Member

The behavior of the compile seems like it's not a bug.

I think it would be better to fix it here:

function setStyle(
style: CSSStyleDeclaration,
name: string,
val: string | string[]
) {
if (isArray(val)) {
val.forEach(v => setStyle(style, name, v))
} else {
if (val == null) val = ''
if (name.startsWith('--')) {
// custom property definition
style.setProperty(name, val)
} else {
const prefixed = autoPrefix(style, name)
if (importantRE.test(val)) {
// !important
style.setProperty(
hyphenate(prefixed),
val.replace(importantRE, ''),
'important'
)
} else {
style[prefixed as any] = val
}
}
}
}

@rudyxu1102
Copy link
Contributor Author

The behavior of the compile seems like it's not a bug.

I think it would be better to fix it here:

function setStyle(
style: CSSStyleDeclaration,
name: string,
val: string | string[]
) {
if (isArray(val)) {
val.forEach(v => setStyle(style, name, v))
} else {
if (val == null) val = ''
if (name.startsWith('--')) {
// custom property definition
style.setProperty(name, val)
} else {
const prefixed = autoPrefix(style, name)
if (importantRE.test(val)) {
// !important
style.setProperty(
hyphenate(prefixed),
val.replace(importantRE, ''),
'important'
)
} else {
style[prefixed as any] = val
}
}
}
}

Thanks, it's a good point. But I still think the compiler should know this is a comment, not a property of style.

@antfu antfu added the ready to merge The PR is ready to be merged. label Oct 3, 2022
packages/shared/src/normalizeProp.ts Outdated Show resolved Hide resolved
Co-authored-by: 三咲智子 <sxzz@sxzz.moe>
Copy link
Member

@sxzz sxzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR title: tranform -> transform

@rudyxu1102 rudyxu1102 changed the title fix(compiler-sfc): ignore style comment in tranform stage fix(compiler-sfc): ignore style comment in transform stage Oct 3, 2022
@netlify
Copy link

netlify bot commented Nov 8, 2022

Deploy Preview for vuejs-coverage failed.

Name Link
🔨 Latest commit 00bbd29
🔍 Latest deploy log https://app.netlify.com/sites/vuejs-coverage/deploys/6369ced11e175f00084724dd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge The PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inline style regular doesn't work when below comments
5 participants