-
Notifications
You must be signed in to change notification settings - Fork 397
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(ssr): do not render class attribute when dynamic value is null, empty or undefined #4960
Conversation
import { DEFAULT_SSR_MODE } from '@lwc/shared'; | ||
import { DEFAULT_SSR_MODE, type CompilationMode } from '@lwc/shared'; | ||
import { expectedFailures } from './utils/expected-failures'; | ||
import type { FeatureFlagName } from '@lwc/features/dist/types'; | ||
import type { CompilationMode } from '../index'; |
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.
Missed this in #4933
if (combinedScopeToken && attrName === 'class') { | ||
attrValue += ' ' + combinedScopeToken; | ||
hasClassAttribute = true; | ||
|
||
if (attrName === 'class') { | ||
if (attrValue === '') { | ||
// If the class attribute is empty, we don't render it. | ||
continue; | ||
} | ||
|
||
if (combinedScopeToken) { | ||
attrValue += ' ' + combinedScopeToken; | ||
hasClassAttribute = true; | ||
} |
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.
I don't normally like to use continue
, but some refactoring would be needed to avoid it here.
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.
Great find! Thanks! 🧸
/nucleus test |
Details
Fixes two expected failures:
'attribute-class/unstyled/dynamic/index.js'
'attribute-class/with-scoped-styles-only-in-parent/dynamic/index.js'
Does this pull request introduce a breaking change?
Does this pull request introduce an observable change?
The class attribute will not be rendered when the dynamic value is null, empty or undefined
GUS work item