|
| 1 | +// @ts-ignore |
| 2 | +import React from 'react'; |
| 3 | + |
| 4 | +import { render } from '../src/renderer/render.js'; |
| 5 | +import { Conditional, Raw } from '../src/index.js'; |
| 6 | + |
| 7 | +describe('<Conditional> + <Raw> interaction', async () => { |
| 8 | + beforeEach(() => { |
| 9 | + vi.restoreAllMocks(); |
| 10 | + vi.resetModules(); |
| 11 | + }); |
| 12 | + |
| 13 | + it('does not corrupt the <![endif]--> closer when Raw is present inside the MSO block', async () => { |
| 14 | + const fragment = ( |
| 15 | + <table role="presentation" cellPadding={0} cellSpacing={0} width={300}> |
| 16 | + <tbody> |
| 17 | + <tr> |
| 18 | + <td> |
| 19 | + <Conditional mso> |
| 20 | + <table role="presentation" width={300}> |
| 21 | + <tbody> |
| 22 | + <tr> |
| 23 | + <td style={{ fontSize: 0, height: 16, width: 16 }}> |
| 24 | + {/* Minimal VML corner via Raw (no comments inside) */} |
| 25 | + <Raw |
| 26 | + content={ |
| 27 | + '<v:shape style="display:block;position:relative;width:16px;height:16px" coordorigin="0 0" coordsize="2 2" fillcolor="#def2f4" fill="true" stroke="f" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word"><v:path v="m 0,2 c 0,1,1,0,2,0 l 2,2 x"/></v:shape>' |
| 28 | + } |
| 29 | + /> |
| 30 | + </td> |
| 31 | + <td style={{ fontSize: 0, height: 16 }} /> |
| 32 | + <td style={{ fontSize: 0, height: 16, width: 16 }}> |
| 33 | + <Raw |
| 34 | + content={ |
| 35 | + '<v:shape style="display:block;position:relative;width:16px;height:16px" coordorigin="0 0" coordsize="2 2" fillcolor="#def2f4" fill="true" stroke="f" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word"><v:path v="m 0,0 c 1,0,2,1,2,2 l 0,2 x"/></v:shape>' |
| 36 | + } |
| 37 | + /> |
| 38 | + </td> |
| 39 | + </tr> |
| 40 | + </tbody> |
| 41 | + </table> |
| 42 | + </Conditional> |
| 43 | + </td> |
| 44 | + </tr> |
| 45 | + </tbody> |
| 46 | + </table> |
| 47 | + ); |
| 48 | + |
| 49 | + const html = await render(fragment, { pretty: true }); |
| 50 | + |
| 51 | + // Known-bad form observed in issue reports |
| 52 | + expect(html).not.toContain('<!--[endif]---->'); |
| 53 | + |
| 54 | + // Valid closer must exist for the MSO block |
| 55 | + const idx = html.indexOf('<![endif]-->', html.indexOf('<!--[if mso]')); |
| 56 | + expect(idx).toBeGreaterThan(-1); |
| 57 | + }); |
| 58 | +}); |
0 commit comments