Skip to content

fix(compat): suppress disabled enumerated attr warning#14931

Closed
leno23 wants to merge 1 commit into
vuejs:mainfrom
leno23:fix-12443-suppress-enumerated-attr-warning
Closed

fix(compat): suppress disabled enumerated attr warning#14931
leno23 wants to merge 1 commit into
vuejs:mainfrom
leno23:fix-12443-suppress-enumerated-attr-warning

Conversation

@leno23
Copy link
Copy Markdown
Contributor

@leno23 leno23 commented Jun 5, 2026

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

    • Improved compatibility mode handling for enumerated attribute coercion
  • Tests

    • Added test coverage for disabled enumerated attribute coercion behavior

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 5, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR fixes enumerated attribute compat coercion gating to correctly respect when the feature is disabled. The implementation switches from softAssertCompatEnabled to checkCompatEnabled, and adds test coverage verifying that disabling the compat flag prevents coercion and suppresses warnings.

Changes

Enumerated Attribute Compat Gating

Layer / File(s) Summary
Compat check and disabled-state test
packages/runtime-dom/src/modules/attrs.ts, packages/vue-compat/__tests__/misc.spec.ts
Switched compatCoerceAttr from softAssertCompatEnabled to checkCompatEnabled for enumerated attribute compat gating. Added test case verifying that when ATTR_ENUMERATED_COERCION is disabled via Vue.configureCompat, coercion is skipped and deprecation warnings are not triggered for draggable, spellcheck, and contenteditable attributes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • vuejs/core#12445: Modifies the same compatCoerceAttr enumerated-attribute coercion flow in packages/runtime-dom/src/modules/attrs.ts
  • vuejs/core#13216: Updates compat-related assertions in packages/runtime-dom/src/modules/attrs.ts and test coverage in packages/vue-compat/__tests__/misc.spec.ts

Suggested labels

ready to merge, :hammer: p3-minor-bug, scope: v2 compat

Suggested reviewers

  • skirtles-code
  • KazariEX

Poem

🐰 A check that danced between two modes,
Now heeds the config's gentle code,
When turned to false, no warnings sound,
A quieter, more truthful ground!
Tests confirm the fix is real—
The compat gate now has its seal! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing the suppression of enumerated attribute warnings when the compat option is disabled.
Linked Issues check ✅ Passed The PR correctly implements the required fix by replacing softAssertCompatEnabled with checkCompatEnabled to ensure warnings are only emitted when the compat behavior is active, and includes test coverage verifying the warning is not called when disabled.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing issue #12443: the attrs.ts modification implements the fix, and the test addition validates the expected behavior.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 106 kB 40.1 kB 36 kB
vue.global.prod.js 164 kB 60.1 kB 53.5 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 48.8 kB 19 kB 17.4 kB
createApp 56.9 kB 22 kB 20.1 kB
createSSRApp 61.2 kB 23.8 kB 21.7 kB
defineCustomElement 63.1 kB 23.9 kB 21.8 kB
overall 71.7 kB 27.4 kB 25 kB

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 5, 2026

Open in StackBlitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@14931
npm i https://pkg.pr.new/@vue/compiler-core@14931
yarn add https://pkg.pr.new/@vue/compiler-core@14931.tgz

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@14931
npm i https://pkg.pr.new/@vue/compiler-dom@14931
yarn add https://pkg.pr.new/@vue/compiler-dom@14931.tgz

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@14931
npm i https://pkg.pr.new/@vue/compiler-sfc@14931
yarn add https://pkg.pr.new/@vue/compiler-sfc@14931.tgz

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@14931
npm i https://pkg.pr.new/@vue/compiler-ssr@14931
yarn add https://pkg.pr.new/@vue/compiler-ssr@14931.tgz

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@14931
npm i https://pkg.pr.new/@vue/reactivity@14931
yarn add https://pkg.pr.new/@vue/reactivity@14931.tgz

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@14931
npm i https://pkg.pr.new/@vue/runtime-core@14931
yarn add https://pkg.pr.new/@vue/runtime-core@14931.tgz

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@14931
npm i https://pkg.pr.new/@vue/runtime-dom@14931
yarn add https://pkg.pr.new/@vue/runtime-dom@14931.tgz

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@14931
npm i https://pkg.pr.new/@vue/server-renderer@14931
yarn add https://pkg.pr.new/@vue/server-renderer@14931.tgz

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@14931
npm i https://pkg.pr.new/@vue/shared@14931
yarn add https://pkg.pr.new/@vue/shared@14931.tgz

vue

pnpm add https://pkg.pr.new/vue@14931
npm i https://pkg.pr.new/vue@14931
yarn add https://pkg.pr.new/vue@14931.tgz

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@14931
npm i https://pkg.pr.new/@vue/compat@14931
yarn add https://pkg.pr.new/@vue/compat@14931.tgz

commit: 30a6780

@leno23 leno23 marked this pull request as ready for review June 5, 2026 09:13
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/vue-compat/__tests__/misc.spec.ts (1)

300-330: ⚡ Quick win

Consider 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 the beforeEach hook sets MODE: 2, it's not guaranteed that this overrides the per-feature flag, which could cause test pollution if subsequent tests depend on the default ATTR_ENUMERATED_COERCION behavior.

Consider one of these approaches:

  1. Add explicit cleanup: Vue.configureCompat({ ATTR_ENUMERATED_COERCION: 'suppress-warning' }) after the assertions
  2. 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

📥 Commits

Reviewing files that changed from the base of the PR and between 9d92dbd and 30a6780.

📒 Files selected for processing (2)
  • packages/runtime-dom/src/modules/attrs.ts
  • packages/vue-compat/__tests__/misc.spec.ts

@edison1105
Copy link
Copy Markdown
Member

duplicate of #12447

@edison1105 edison1105 closed this Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setting ATTR_ENUMERATED_COERCION compat to false does not disable warning

2 participants