Skip to content

Commit 77903a0

Browse files
committed
fix: handle edge case in stringifyStatic
1 parent 2ed535b commit 77903a0

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

packages/compiler-dom/__tests__/transforms/stringifyStatic.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,23 @@ describe('stringify static html', () => {
389389
])
390390
})
391391

392+
test('should remove overloaded boolean attribute for `false`', () => {
393+
const { ast } = compileWithStringify(
394+
`<div>
395+
${repeat(
396+
`<span :hidden="false"></span>`,
397+
StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
398+
)}
399+
</div>`,
400+
)
401+
expect(ast.cached).toMatchObject([
402+
cachedArrayStaticNodeMatcher(
403+
repeat(`<span></span>`, StringifyThresholds.ELEMENT_WITH_BINDING_COUNT),
404+
StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
405+
),
406+
])
407+
})
408+
392409
test('should stringify svg', () => {
393410
const svg = `<svg width="50" height="50" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg">`
394411
const repeated = `<rect width="50" height="50" fill="#C4C4C4"></rect>`

packages/compiler-dom/src/transforms/stringifyStatic.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
isKnownHtmlAttr,
2727
isKnownMathMLAttr,
2828
isKnownSvgAttr,
29+
isOverloadedBooleanAttr,
2930
isString,
3031
isSymbol,
3132
isVoidTag,
@@ -341,7 +342,8 @@ function stringifyElement(
341342
}
342343
// #6568
343344
if (
344-
isBooleanAttr((p.arg as SimpleExpressionNode).content) &&
345+
(isBooleanAttr((p.arg as SimpleExpressionNode).content) ||
346+
isOverloadedBooleanAttr((p.arg as SimpleExpressionNode).content)) &&
345347
exp.content === 'false'
346348
) {
347349
continue

0 commit comments

Comments
 (0)