Skip to content

Commit

Permalink
Add test for flushing SVG within <marp-auto-scaling>
Browse files Browse the repository at this point in the history
  • Loading branch information
yhatt committed Aug 11, 2022
1 parent 77de38e commit 61a2938
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/custom-elements/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,5 +263,33 @@ describe('The hydration script for custom elements', () => {
expect(overloaded.container.style.marginRight).toBe('0px')
expect(overloaded.container.style.marginLeft).toBe('auto')
})

describe('Rendering workaround for Chromium 105+', () => {
const waitNextRendering = () =>
new Promise<void>((resolve) => requestAnimationFrame(() => resolve()))

it("flushes SVG's display style on mounted", async () => {
expect.hasAssertions()

browser.applyCustomElements()
document.body.innerHTML = '<marp-auto-scaling>test</marp-auto-scaling>'

const autoScaling = document.querySelector(
'marp-auto-scaling'
) as MarpAutoScaling
const svg = autoScaling.shadowRoot.querySelector('svg') as SVGElement

// Initially SVG's display style is not set
expect(svg.style.display).toBe('')

// At the next rendering frame, display style is set as `inline`
await waitNextRendering()
expect(svg.style.display).toBe('inline')

// After that, display style is reverted to empty string
await waitNextRendering()
expect(svg.style.display).toBe('')
})
})
})
})

0 comments on commit 61a2938

Please sign in to comment.