Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 8 additions & 1 deletion demo/performance/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default class CommonTest {
title: 'test',
content1: 'AAA',
content2: 'BBB',
items: [{ text: 'one' }, { text: 'two' }, { text: 'three' }],
},
{
attr: '456',
Expand All @@ -76,6 +77,7 @@ export default class CommonTest {
title: 'test',
content1: 'ZZZ',
content2: 'BBB',
items: [{ text: 'one' }, { text: 'two' }, { text: 'three' }, { text: 'four' }, { text: 'five' }, { text: 'six' }],
},
];

Expand Down Expand Up @@ -235,14 +237,19 @@ export class HtmlLiteralInterface {
// We can get around the optimization by using eval though!
static getResultEval(html, properties) {
// eslint-disable-next-line no-unused-vars
const { attr, one, two, three, four, five, six, seven, eight, nine, ten, id, hidden, title, content1, content2 } = properties;
const { attr, one, two, three, four, five, six, seven, eight, nine, ten, id, hidden, title, content1, content2, items } = properties;
// eslint-disable-next-line no-eval
return eval(`html\`<div data-id="p1" attr="\${attr}">
<div data-id="p2" data-foo one="\${one}" two="\${two}" three="\${three}" four="\${four}" five="\${five}" .six="\${six}" .seven="\${seven}" .eight="\${eight}" .nine="\${nine}" .ten="\${ten}">
<div data-id="p3" data-bar="bar">
<div data-id="\${id}" boolean ?hidden="\${hidden}" .title="\${title}">
\${content1} -- \${content2}
</div>
<ul data-id="list">
\${(items ?? []).map(item => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Easy peasy to test / compare performance of this stuff — we might as well.

return html\`<li>\${item.text}</li>\`;
})}
</ul>
</div>
</div>
<div class="extra">
Expand Down
5 changes: 4 additions & 1 deletion demo/performance/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Test extends CommonTest {

// TODO: This is sorta cheating since we aren’t asking it to _parse_ anything…
static getResult(properties) {
const { attr, one, two, three, four, five, six, seven, eight, nine, ten, id, hidden, title, content1, content2 } = properties;
const { attr, one, two, three, four, five, six, seven, eight, nine, ten, id, hidden, title, content1, content2, items } = properties;
return createElement('div', { 'data-id': 'p1', attr }, [
createElement('div', { 'data-id': 'p2', 'data-foo': '', one, two, three, four, five, six, seven, eight, nine, ten }, [
createElement('div', { 'data-id': 'p3', 'data-bar': 'bar' }, [
Expand All @@ -20,6 +20,9 @@ class Test extends CommonTest {
' -- ',
content2,
]),
createElement('ul', { 'data-id': 'list' }, (items ?? []).map(item => {
return createElement('li', null, [item.text]);
})),
]),
createElement('p', null, [
'Just something a little ',
Expand Down
4 changes: 4 additions & 0 deletions test/test-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1544,12 +1544,16 @@ describe('errors coverage', () => {
assertThrows(callback, expectedMessage, { startsWith: true });
});

//////////////////////////////////////////////////////////////////////////////
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed adding these error-code-block delimiters to the parser tests before. Sneaking them in.


it('throws when cdata exists', () => {
const callback = () => htmlol`<![CDATA[<]]>`;
const expectedMessage = '[#140]';
assertThrows(callback, expectedMessage, { startsWith: true });
});

//////////////////////////////////////////////////////////////////////////////

it('throws when escapes are used', () => {
const callback = () => htmlol`\n`;
const expectedMessage = '[#150]';
Expand Down