File tree 1 file changed +16
-3
lines changed
src/server/optimizing-compiler
1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,11 @@ import {
11
11
isRenderableAttr
12
12
} from 'web/server/util'
13
13
14
+ import {
15
+ isBooleanAttr ,
16
+ isEnumeratedAttr
17
+ } from 'web/util/attrs'
18
+
14
19
import type { StringSegment } from './codegen'
15
20
import type { CodegenState } from 'compiler/codegen/index'
16
21
@@ -56,11 +61,19 @@ export function genDOMPropSegments (
56
61
57
62
function genAttrSegment ( name : string , value : string ) : StringSegment {
58
63
if ( plainStringRE . test ( value ) ) {
64
+ // force double quote
65
+ value = value . replace ( / ^ ' | ' $ / g, '"' )
66
+ // force enumerated attr to "true"
67
+ if ( isEnumeratedAttr ( name ) && value !== `"false"` ) {
68
+ value = `"true"`
69
+ }
59
70
return {
60
71
type : RAW ,
61
- value : value === '""'
62
- ? ` ${ name } `
63
- : ` ${ name } =${ value } `
72
+ value : isBooleanAttr ( name )
73
+ ? ` ${ name } ="${ name } "`
74
+ : value === '""'
75
+ ? ` ${ name } `
76
+ : ` ${ name } =${ value } `
64
77
}
65
78
} else {
66
79
return {
You can’t perform that action at this time.
0 commit comments