Skip to content

Commit

Permalink
test: wait for rAF in the non-shadow-dom test
Browse files Browse the repository at this point in the history
`html-parsed-element` schedules `parsedCallback` in rAF, so we have to
wait for at least an animation frame (`nextTick` is not enough)
to ensure the element is fully initialized.

https://github.com/WebReflection/html-parsed-element/blob/11081fc102e2eec745a1a1d32723eef342df2452/index.js#L34
  • Loading branch information
haoqunjiang committed Aug 29, 2023
1 parent 9f1b87a commit aa8dd6d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/runtime-dom/__tests__/customElement.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,16 @@ describe('defineCustomElement', () => {
)
customElements.define('my-el-shadowroot-false', E)

test('should work', () => {
test('should work', async () => {
function raf() {
return new Promise(resolve => {
requestAnimationFrame(resolve)
})
}

container.innerHTML = `<my-el-shadowroot-false></my-el-shadowroot-false>`
const e = container.childNodes[0] as VueElement
await raf()
expect(e).toBeInstanceOf(E)
expect(e._instance).toBeTruthy()
expect(e.innerHTML).toBe(`<div>hello</div>`)
Expand Down

0 comments on commit aa8dd6d

Please sign in to comment.