Skip to content

convert to typescript, add comment tag, text node #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add svg test case
  • Loading branch information
wongchichong committed Mar 1, 2023
commit 854c251a5a2f5f34a2c16d745aba5f64bd7d3c11
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "vhtml",
"amdName": "vhtml",
"version": "2.2.0",
"version": "2.2.1",
"description": "Hyperscript reviver that constructs a sanitized HTML string.",
"main": "dist/vhtml.js",
"minified:main": "dist/vhtml.min.js",
"jsnext:main": "src/vhtml.js",
"scripts": {
"preinstall": "npx only-allow pnpm",
"build": "vite build && tsc --declaration && pnpm size",
"tsc": "tsc",
"size": "echo \"gzip size: $(gzip-size $npm_package_minified_main | pretty-bytes)\"",
Expand Down
35 changes: 11 additions & 24 deletions test/vhtml.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,34 +195,21 @@ describe('vhtml', () => {
)
})

it('should support sortof components without args but with children', () => {
let items = ['one', 'two']

const Item = ({ children }) => (
<li>
<h4></h4>
{children}
</li>
)

it('should support svg', () => {
expect(
< !--comments -->
<div class="foo">
<h1>Hi!</h1>
<ul>
{items.map((item, index) => (
<Item>
This is item {item}!
</Item>
))}
</ul>
</div>
<svg viewBox="0 0 100 100">
<g transform="translate(50, 50)">
<circle class="clock-face" r={48} />
<line class="millisecond" y2={-44} />
<line class="hour" y2={-22} />
<line class="minute" y2={-32} />
<line class="second" y2={-38} />
</g>
</svg>
).to.equal(
`<div class="foo"><h1>Hi!</h1><ul><li><h4></h4>This is item one!</li><li><h4></h4>This is item two!</li></ul></div>`
`<svg viewBox="0 0 100 100"><g transform="translate(50, 50)"><circle class="clock-face" r="48"></circle><line class="millisecond" y2="-44"></line><line class="hour" y2="-22"></line><line class="minute" y2="-32"></line><line class="second" y2="-38"></line></g></svg>`
)
})


it('should support empty comment', () => {
expect(
h('!', null)
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy