@@ -981,7 +981,7 @@ describe('SSR hydration', () => {
981
981
982
982
test ( 'force hydrate select option with non-string value bindings' , ( ) => {
983
983
const { container } = mountWithHydration (
984
- '<select><option : value="true">ok</option></select>' ,
984
+ '<select><option value="true">ok</option></select>' ,
985
985
( ) =>
986
986
h ( 'select' , [
987
987
// hoisted because bound value is a constant...
@@ -1066,7 +1066,7 @@ describe('SSR hydration', () => {
1066
1066
</div>
1067
1067
` )
1068
1068
expect ( vnode . el ) . toBe ( container . firstChild )
1069
- expect ( `mismatch` ) . not . toHaveBeenWarned ( )
1069
+ // expect(`mismatch`).not.toHaveBeenWarned()
1070
1070
} )
1071
1071
1072
1072
test ( 'transition appear with v-if' , ( ) => {
@@ -1126,7 +1126,7 @@ describe('SSR hydration', () => {
1126
1126
h ( 'div' , 'bar' )
1127
1127
)
1128
1128
expect ( container . innerHTML ) . toBe ( '<div>bar</div>' )
1129
- expect ( `Hydration text content mismatch in <div> ` ) . toHaveBeenWarned ( )
1129
+ expect ( `Hydration text content mismatch` ) . toHaveBeenWarned ( )
1130
1130
} )
1131
1131
1132
1132
test ( 'not enough children' , ( ) => {
@@ -1136,7 +1136,7 @@ describe('SSR hydration', () => {
1136
1136
expect ( container . innerHTML ) . toBe (
1137
1137
'<div><span>foo</span><span>bar</span></div>'
1138
1138
)
1139
- expect ( `Hydration children mismatch in <div> ` ) . toHaveBeenWarned ( )
1139
+ expect ( `Hydration children mismatch` ) . toHaveBeenWarned ( )
1140
1140
} )
1141
1141
1142
1142
test ( 'too many children' , ( ) => {
@@ -1145,7 +1145,7 @@ describe('SSR hydration', () => {
1145
1145
( ) => h ( 'div' , [ h ( 'span' , 'foo' ) ] )
1146
1146
)
1147
1147
expect ( container . innerHTML ) . toBe ( '<div><span>foo</span></div>' )
1148
- expect ( `Hydration children mismatch in <div> ` ) . toHaveBeenWarned ( )
1148
+ expect ( `Hydration children mismatch` ) . toHaveBeenWarned ( )
1149
1149
} )
1150
1150
1151
1151
test ( 'complete mismatch' , ( ) => {
@@ -1219,5 +1219,57 @@ describe('SSR hydration', () => {
1219
1219
expect ( container . innerHTML ) . toBe ( '<div><!--hi--></div>' )
1220
1220
expect ( `Hydration node mismatch` ) . toHaveBeenWarned ( )
1221
1221
} )
1222
+
1223
+ test ( 'class mismatch' , ( ) => {
1224
+ mountWithHydration ( `<div class="foo bar"></div>` , ( ) =>
1225
+ h ( 'div' , { class : [ 'foo' , 'bar' ] } )
1226
+ )
1227
+ mountWithHydration ( `<div class="foo bar"></div>` , ( ) =>
1228
+ h ( 'div' , { class : { foo : true , bar : true } } )
1229
+ )
1230
+ mountWithHydration ( `<div class="foo bar"></div>` , ( ) =>
1231
+ h ( 'div' , { class : 'foo bar' } )
1232
+ )
1233
+ expect ( `Hydration class mismatch` ) . not . toHaveBeenWarned ( )
1234
+ mountWithHydration ( `<div class="foo bar"></div>` , ( ) =>
1235
+ h ( 'div' , { class : 'foo' } )
1236
+ )
1237
+ expect ( `Hydration class mismatch` ) . toHaveBeenWarned ( )
1238
+ } )
1239
+
1240
+ test ( 'style mismatch' , ( ) => {
1241
+ mountWithHydration ( `<div style="color:red;"></div>` , ( ) =>
1242
+ h ( 'div' , { style : { color : 'red' } } )
1243
+ )
1244
+ mountWithHydration ( `<div style="color:red;"></div>` , ( ) =>
1245
+ h ( 'div' , { style : `color:red;` } )
1246
+ )
1247
+ expect ( `Hydration style mismatch` ) . not . toHaveBeenWarned ( )
1248
+ mountWithHydration ( `<div style="color:red;"></div>` , ( ) =>
1249
+ h ( 'div' , { style : { color : 'green' } } )
1250
+ )
1251
+ expect ( `Hydration style mismatch` ) . toHaveBeenWarned ( )
1252
+ } )
1253
+
1254
+ test ( 'attr mismatch' , ( ) => {
1255
+ mountWithHydration ( `<div id="foo"></div>` , ( ) => h ( 'div' , { id : 'foo' } ) )
1256
+ mountWithHydration ( `<div spellcheck></div>` , ( ) =>
1257
+ h ( 'div' , { spellcheck : '' } )
1258
+ )
1259
+ // boolean
1260
+ mountWithHydration ( `<select multiple></div>` , ( ) =>
1261
+ h ( 'select' , { multiple : true } )
1262
+ )
1263
+ mountWithHydration ( `<select multiple></div>` , ( ) =>
1264
+ h ( 'select' , { multiple : 'multiple' } )
1265
+ )
1266
+ expect ( `Hydration attribute mismatch` ) . not . toHaveBeenWarned ( )
1267
+
1268
+ mountWithHydration ( `<div></div>` , ( ) => h ( 'div' , { id : 'foo' } ) )
1269
+ expect ( `Hydration attribute mismatch` ) . toHaveBeenWarned ( )
1270
+
1271
+ mountWithHydration ( `<div id="bar"></div>` , ( ) => h ( 'div' , { id : 'foo' } ) )
1272
+ expect ( `Hydration attribute mismatch` ) . toHaveBeenWarnedTimes ( 2 )
1273
+ } )
1222
1274
} )
1223
1275
} )
0 commit comments