fix(compat): suppress disabled enumerated attr warning#14931
Conversation
📝 WalkthroughWalkthroughThis PR fixes enumerated attribute compat coercion gating to correctly respect when the feature is disabled. The implementation switches from ChangesEnumerated Attribute Compat Gating
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/vue-compat/__tests__/misc.spec.ts (1)
300-330: ⚡ Quick winConsider resetting the compat config or using component-level
compatConfig.The test calls
Vue.configureCompat({ ATTR_ENUMERATED_COERCION: false })to set global state, but doesn't explicitly reset this setting afterward. While thebeforeEachhook setsMODE: 2, it's not guaranteed that this overrides the per-feature flag, which could cause test pollution if subsequent tests depend on the defaultATTR_ENUMERATED_COERCIONbehavior.Consider one of these approaches:
- Add explicit cleanup:
Vue.configureCompat({ ATTR_ENUMERATED_COERCION: 'suppress-warning' })after the assertions- Use component-level config (as seen in lines 228-230 for
ATTR_FALSE_VALUE):const vm = new Vue({ template: `<div :draggable="null" :spellcheck="false" contenteditable="foo" />`, compatConfig: { ATTR_ENUMERATED_COERCION: false, }, }).$mount()Component-level config is scoped and avoids global state entirely.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/vue-compat/__tests__/misc.spec.ts` around lines 300 - 330, The test "ATTR_ENUMERATED_COERCION disabled" mutates global state via Vue.configureCompat({ ATTR_ENUMERATED_COERCION: false }) and doesn't restore it, risking test pollution; change it to use a component-scoped compatConfig on the Vue instance (add compatConfig: { ATTR_ENUMERATED_COERCION: false } to the new Vue({...}) in the test) or, if you must keep the global call, explicitly reset it after assertions by calling Vue.configureCompat({ ATTR_ENUMERATED_COERCION: 'suppress-warning' }) to restore the default behavior; update references to Vue.configureCompat and the Vue constructor in this test accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/vue-compat/__tests__/misc.spec.ts`:
- Around line 300-330: The test "ATTR_ENUMERATED_COERCION disabled" mutates
global state via Vue.configureCompat({ ATTR_ENUMERATED_COERCION: false }) and
doesn't restore it, risking test pollution; change it to use a component-scoped
compatConfig on the Vue instance (add compatConfig: { ATTR_ENUMERATED_COERCION:
false } to the new Vue({...}) in the test) or, if you must keep the global call,
explicitly reset it after assertions by calling Vue.configureCompat({
ATTR_ENUMERATED_COERCION: 'suppress-warning' }) to restore the default behavior;
update references to Vue.configureCompat and the Vue constructor in this test
accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9237dc9d-82b6-43bf-8ec2-402293bc0266
📒 Files selected for processing (2)
packages/runtime-dom/src/modules/attrs.tspackages/vue-compat/__tests__/misc.spec.ts
|
duplicate of #12447 |
Fixes #12443.\n\nATTR_ENUMERATED_COERCION used softAssertCompatEnabled, which warns even when the compat behavior is disabled. Use checkCompatEnabled so the warning is emitted only when the compat coercion is active, matching the deprecation message that configureCompat({ ATTR_ENUMERATED_COERCION: false }) suppresses the warning.\n\nTest: pnpm vitest packages/vue-compat/tests/misc.spec.ts --run
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests