Skip to content

Commit

Permalink
fix #234
Browse files Browse the repository at this point in the history
kind of a hack but it works for this edge case
  • Loading branch information
quantizor committed Mar 18, 2019
1 parent 544845c commit d815885
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 4 deletions.
114 changes: 111 additions & 3 deletions index.compiler.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,114 @@ it('#190 perf regression', () => {
`);
});

it('#234 perf regression', () => {
render(
compiler(
`<br /><b>1</b><b>2</b><b>3</b><b>4</b><b>5</b><b>6</b><b>7</b><b>8</b><b>9</b><b>10</b>
<b>1</b><b>2</b><b>3</b><b>4</b><b>5</b><b>6</b><b>7</b><b>8</b><b>9</b><b>20</b>
<b>1</b><b>2</b><b>3</b><b>4</b><b>5</b><b>6</b><b>7</b><b>8</b><b>9</b><b>30</b>`
)
);

expect(root.innerHTML).toMatchInlineSnapshot(`
<div data-reactroot>
<br>
<b>
1
</b>
<b>
2
</b>
<b>
3
</b>
<b>
4
</b>
<b>
5
</b>
<b>
6
</b>
<b>
7
</b>
<b>
8
</b>
<b>
9
</b>
<b>
10
</b>
<b>
1
</b>
<b>
2
</b>
<b>
3
</b>
<b>
4
</b>
<b>
5
</b>
<b>
6
</b>
<b>
7
</b>
<b>
8
</b>
<b>
9
</b>
<b>
20
</b>
<b>
1
</b>
<b>
2
</b>
<b>
3
</b>
<b>
4
</b>
<b>
5
</b>
<b>
6
</b>
<b>
7
</b>
<b>
8
</b>
<b>
9
</b>
<b>
30
</b>
</div>
`);
});

describe('inline textual elements', () => {
it('should handle emphasized text', () => {
render(compiler('*Hello.*'));
Expand Down Expand Up @@ -2845,14 +2953,14 @@ describe('overrides', () => {
it('should override the title property when parsing a link', () => {
class FakeLink extends React.Component {
render() {
const {title, children} = this.props
return <a title={title}>{children}</a>
const { title, children } = this.props;
return <a title={title}>{children}</a>;
}
}

render(
compiler('[link](https://example.org)', {
overrides: { a: {component: FakeLink, props: { title: 'foo' } } },
overrides: { a: { component: FakeLink, props: { title: 'foo' } } },
})
);

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const HEADING_SETEXT_R = /^([^\n]+)\n *(=|-){3,} *(?:\n *)+\n/;
* 6. Capture excess newlines afterward
* \n*
*/
const HTML_BLOCK_ELEMENT_R = /^ *<([A-Za-z][^ >/]*) ?([^>]*)\/{0}>\n?(\s*(?:<\1[^>]*?>[\s\S]*?<\/\1>|(?!<\1)[\s\S])*?)<\/\1>\n*/;
const HTML_BLOCK_ELEMENT_R = /^ *(?!<[a-z][^ >/]* ?\/>)<([a-z][^ >/]*) ?([^>]*)\/{0}>\n?(\s*(?:<\1[^>]*?>[\s\S]*?<\/\1>|(?!<\1)[\s\S])*?)<\/\1>\n*/i;

const HTML_CHAR_CODE_R = /&([a-z]+);/g;

Expand Down

0 comments on commit d815885

Please sign in to comment.