This commit is contained in:
yangxiuxiu 2025-07-01 11:03:51 +02:00 committed by GitHub
commit 471a3d1e19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 5 deletions

View File

@ -59,11 +59,11 @@ export function compatCoerceAttr(
): boolean {
if (isEnumeratedAttr(key)) {
const v2CoercedValue =
value === null
? 'false'
: typeof value !== 'boolean' && value !== undefined
? 'true'
: null
value === undefined
? null
: value === null || value === false || value === 'false'
? 'false'
: 'true'
if (
v2CoercedValue &&
compatUtils.softAssertCompatEnabled(

View File

@ -275,3 +275,17 @@ test('ATTR_ENUMERATED_COERCION', () => {
)('contenteditable', 'foo', 'true'),
).toHaveBeenWarned()
})
test('ATTR_ENUMERATED_COERCION: true', () => {
const vm = new Vue({
compatConfig: { ATTR_ENUMERATED_COERCION: true },
template: `<div><div draggable="false">hello</div></div>`,
}).$mount()
expect(vm.$el.innerHTML).toBe(`<div draggable="false">hello</div>`)
expect(
(
deprecationData[DeprecationTypes.ATTR_ENUMERATED_COERCION]
.message as Function
)('draggable', 'false', 'false'),
).toHaveBeenWarned()
})