Skip to content

Commit

Permalink
stricter testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jennspencer committed Jun 16, 2024
1 parent b64caca commit 023c2e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion components/HTMLBlock/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const extractScripts = (html: string = ''): [string, () => void] => {

const HTMLBlock = ({ children = '', runScripts, safeMode = false }) => {
let html = children;
runScripts = runScripts === 'true' ? true : false;
runScripts = typeof runScripts !== 'boolean' ? (runScripts === 'true' ? true : false) : runScripts;

if (typeof html !== 'string') html = renderToStaticMarkup(html);
const [cleanedHtml, exec] = extractScripts(html);
Expand Down
12 changes: 4 additions & 8 deletions docs/html-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,14 @@ title: 'HTML Blocks'

## HTML in template literal

<HTMLBlock>
{`
<HTMLBlock>{`
<script>console.log(true, 3);</script>
<h3>Header 3</h3>
<p>Paragraph with <em>italics</em> and <strong>bold stuff</strong>.</p>
<div style="padding-left: 20px; color: blue">
Behold, I am blue and indented!
</div>
`}
</HTMLBlock>
`}</HTMLBlock>


## JSX in safe mode
Expand All @@ -59,13 +57,11 @@ title: 'HTML Blocks'

## HTML in safe mode

<HTMLBlock safeMode={true}>
{`
<HTMLBlock safeMode={true}>{`
<script>console.log(true, 5);</script>
<h3>Header 5</h3>
<p>Paragraph with <em>italics</em> and <strong>bold stuff</strong>.</p>
<div style="padding-left: 20px; color: blue">
Behold, I am blue and indented!
</div>
`}
</HTMLBlock>
`}</HTMLBlock>

0 comments on commit 023c2e7

Please sign in to comment.