Skip to content

Commit d815885

Browse files
committed
fix #234
kind of a hack but it works for this edge case
1 parent 544845c commit d815885

File tree

2 files changed

+112
-4
lines changed

2 files changed

+112
-4
lines changed

index.compiler.spec.js

Lines changed: 111 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,114 @@ it('#190 perf regression', () => {
101101
`);
102102
});
103103

104+
it('#234 perf regression', () => {
105+
render(
106+
compiler(
107+
`<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>
108+
<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>
109+
<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>`
110+
)
111+
);
112+
113+
expect(root.innerHTML).toMatchInlineSnapshot(`
114+
115+
<div data-reactroot>
116+
<br>
117+
<b>
118+
1
119+
</b>
120+
<b>
121+
2
122+
</b>
123+
<b>
124+
3
125+
</b>
126+
<b>
127+
4
128+
</b>
129+
<b>
130+
5
131+
</b>
132+
<b>
133+
6
134+
</b>
135+
<b>
136+
7
137+
</b>
138+
<b>
139+
8
140+
</b>
141+
<b>
142+
9
143+
</b>
144+
<b>
145+
10
146+
</b>
147+
<b>
148+
1
149+
</b>
150+
<b>
151+
2
152+
</b>
153+
<b>
154+
3
155+
</b>
156+
<b>
157+
4
158+
</b>
159+
<b>
160+
5
161+
</b>
162+
<b>
163+
6
164+
</b>
165+
<b>
166+
7
167+
</b>
168+
<b>
169+
8
170+
</b>
171+
<b>
172+
9
173+
</b>
174+
<b>
175+
20
176+
</b>
177+
<b>
178+
1
179+
</b>
180+
<b>
181+
2
182+
</b>
183+
<b>
184+
3
185+
</b>
186+
<b>
187+
4
188+
</b>
189+
<b>
190+
5
191+
</b>
192+
<b>
193+
6
194+
</b>
195+
<b>
196+
7
197+
</b>
198+
<b>
199+
8
200+
</b>
201+
<b>
202+
9
203+
</b>
204+
<b>
205+
30
206+
</b>
207+
</div>
208+
209+
`);
210+
});
211+
104212
describe('inline textual elements', () => {
105213
it('should handle emphasized text', () => {
106214
render(compiler('*Hello.*'));
@@ -2845,14 +2953,14 @@ describe('overrides', () => {
28452953
it('should override the title property when parsing a link', () => {
28462954
class FakeLink extends React.Component {
28472955
render() {
2848-
const {title, children} = this.props
2849-
return <a title={title}>{children}</a>
2956+
const { title, children } = this.props;
2957+
return <a title={title}>{children}</a>;
28502958
}
28512959
}
28522960

28532961
render(
28542962
compiler('[link](https://example.org)', {
2855-
overrides: { a: {component: FakeLink, props: { title: 'foo' } } },
2963+
overrides: { a: { component: FakeLink, props: { title: 'foo' } } },
28562964
})
28572965
);
28582966

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ const HEADING_SETEXT_R = /^([^\n]+)\n *(=|-){3,} *(?:\n *)+\n/;
140140
* 6. Capture excess newlines afterward
141141
* \n*
142142
*/
143-
const HTML_BLOCK_ELEMENT_R = /^ *<([A-Za-z][^ >/]*) ?([^>]*)\/{0}>\n?(\s*(?:<\1[^>]*?>[\s\S]*?<\/\1>|(?!<\1)[\s\S])*?)<\/\1>\n*/;
143+
const HTML_BLOCK_ELEMENT_R = /^ *(?!<[a-z][^ >/]* ?\/>)<([a-z][^ >/]*) ?([^>]*)\/{0}>\n?(\s*(?:<\1[^>]*?>[\s\S]*?<\/\1>|(?!<\1)[\s\S])*?)<\/\1>\n*/i;
144144

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

0 commit comments

Comments
 (0)