diff --git a/README.md b/README.md index ffeee26..e4c18be 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ app initialization. That could be useful to generate HTML markup from static vie ```js import { renderToString } from 'hyperapp-render' -const Component = (props) =>

Hello {props.name}

+const Component = ({ name }) =>

Hello {name}

renderToString() // =>

Hello World

@@ -106,7 +106,7 @@ Also consider the list of browsers supported by [hyperapp](https://github.com/hy ## Caveats The library automatically escapes text content and attribute values -of [virtual DOM nodes](https://github.com/hyperapp/hyperapp/blob/1.1.1/README.md#virtual-dom) +of [virtual DOM nodes](https://github.com/hyperapp/hyperapp/blob/1.1.2/README.md#virtual-dom) to protect your application against [XSS](https://en.wikipedia.org/wiki/Cross-site_scripting) attacks. However, it is not safe to allow "user input" for node names or attribute keys because @@ -118,8 +118,8 @@ const tagName = 'div onclick="alert(1)"' renderToString(h(tagName, { title: 'Hey' }, 'Hi')) // =>
Hi
-const propName = 'onclick="alert(1)" title' -renderToString(h('div', { [propName]: 'Hey' }, 'Hi')) +const attributeName = 'onclick="alert(1)" title' +renderToString(h('div', { [attributeName]: 'Hey' }, 'Hi')) // =>
Hi
const userInput = '' diff --git a/benchmark/index.bench.js b/benchmark/index.bench.js index d2b397c..05342c6 100644 --- a/benchmark/index.bench.js +++ b/benchmark/index.bench.js @@ -77,8 +77,8 @@ suite('renderAttribute(name, value)', () => { }) suite('renderToString(node)', () => { - const Fragment = (props, children) => h('', props, children) - const Component = (props, children) =>

{children}

+ const Fragment = (attributes, children) => h('', attributes, children) + const Component = (attributes, children) =>

{children}

benchmark('basic', () => { renderToString( diff --git a/demo.gif b/demo.gif index f4284b6..cffe4a8 100644 Binary files a/demo.gif and b/demo.gif differ diff --git a/test/index.spec.js b/test/index.spec.js index 6852a90..18f2eaf 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -297,7 +297,7 @@ describe('renderToString(node)', () => { }) it('should render composite components', () => { - const Child = (props) =>

Hello {props.name}

+ const Child = ({ name }) =>

Hello {name}

const Parent = () => (