@@ -215,6 +215,30 @@ describe('defineCustomElement', () => {
215
215
expect ( el . hasAttribute ( 'not-prop' ) ) . toBe ( false )
216
216
} )
217
217
218
+ test ( 'handle properties set before connecting' , ( ) => {
219
+ const obj = { a : 1 }
220
+ const E = defineCustomElement ( {
221
+ props : {
222
+ foo : String ,
223
+ post : Object
224
+ } ,
225
+ setup ( props ) {
226
+ expect ( props . foo ) . toBe ( 'hello' )
227
+ expect ( props . post ) . toBe ( obj )
228
+ } ,
229
+ render ( ) {
230
+ return JSON . stringify ( this . post )
231
+ }
232
+ } )
233
+ customElements . define ( 'my-el-preconnect' , E )
234
+ const el = document . createElement ( 'my-el-preconnect' ) as any
235
+ el . foo = 'hello'
236
+ el . post = obj
237
+
238
+ container . appendChild ( el )
239
+ expect ( el . shadowRoot . innerHTML ) . toBe ( JSON . stringify ( obj ) )
240
+ } )
241
+
218
242
// https://github.com/vuejs/core/issues/6163
219
243
test ( 'handle components with no props' , async ( ) => {
220
244
const E = defineCustomElement ( {
@@ -247,29 +271,6 @@ describe('defineCustomElement', () => {
247
271
expect ( el . maxAge ) . toBe ( 50 )
248
272
expect ( el . shadowRoot . innerHTML ) . toBe ( 'max age: 50/type: number' )
249
273
} )
250
-
251
- test ( 'handle properties set before connecting' , ( ) => {
252
- const obj = { }
253
- const E = defineCustomElement ( {
254
- props : {
255
- foo : String ,
256
- post : Object
257
- } ,
258
- setup ( props ) {
259
- expect ( props . foo ) . toBe ( 'hello' )
260
- expect ( props . post ) . toBe ( obj )
261
- } ,
262
- render ( ) {
263
- return `foo: ${ this . foo } `
264
- }
265
- } )
266
- customElements . define ( 'my-el-preconnect' , E )
267
- const el = document . createElement ( 'my-el-preconnect' ) as any
268
- el . foo = 'hello'
269
- el . post = obj
270
-
271
- container . appendChild ( el )
272
- } )
273
274
} )
274
275
275
276
describe ( 'attrs' , ( ) => {
0 commit comments