Skip to content

Commit e15d59f

Browse files
committed
chore(benchmarking): fix benchmarking app
1 parent a993707 commit e15d59f

File tree

7 files changed

+43
-29
lines changed

7 files changed

+43
-29
lines changed

apps/benchmarking/profiles.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import ProfileSimple from './profiles/ProfileSimple';
1+
// import ProfileSimple from './profiles/ProfileSimple';
22
import ProfileV5 from './profiles/ProfileV5';
33
import ProfileV6Source from './profiles/ProfileV6Source';
44

55
const profiles = [
6-
{
7-
name: 'Simple implementation',
8-
component: ProfileSimple
9-
},
6+
// Disabled because of htmlparser resolution
7+
// {
8+
// name: 'Simple implementation',
9+
// component: ProfileSimple
10+
// },
1011
{
1112
name: 'V5',
1213
component: ProfileV5

apps/benchmarking/profiles/ProfileSimple.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import RenderHtmlSimple from './RenderHtmlSimple';
33

4-
export default function ProfileSimple({running, html, ignoredTags}) {
4+
export default function ProfileSimple({ running, html, ignoredTags }) {
55
return (
66
html &&
77
running && <RenderHtmlSimple ignoredTags={ignoredTags} html={html} />
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react';
22
import RenderHtmlv5 from 'react-native-render-html-v5';
33

4-
export default function ProfileV5({running, ignoredTags, html}) {
4+
export default function ProfileV5({ running, ignoredTags, html }) {
55
return (
66
html &&
7-
running && <RenderHtmlv5 ignoredTags={ignoredTags} source={{html}} />
7+
running && <RenderHtmlv5 ignoredTags={ignoredTags} source={{ html }} />
88
);
99
}
Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
1-
import {Text, View, Image} from 'react-native';
2-
import {parseDocument, ElementType} from 'htmlparser2';
3-
import React, {PureComponent} from 'react';
1+
import { Text, View, Image } from 'react-native';
2+
import { parseDocument, ElementType } from 'htmlparser2';
3+
import React, { PureComponent } from 'react';
44

55
export default class RenderHtmlSimple extends PureComponent {
6-
ignoredTags = ['head'];
7-
textTags = ['span', 'strong', 'em'];
8-
96
constructor(props) {
107
super(props);
118
this.ignoredTags = props.ignoredTags || this.ignoredTags;
129
}
1310

14-
renderTextNode(textNode, index) {
15-
return <Text key={index}>{textNode.data}</Text>;
11+
ignoredTags = ['head'];
12+
13+
render() {
14+
const { html, ...viewProps } = this.props;
15+
const document = parseDocument(html);
16+
return (
17+
<View {...viewProps}>
18+
{document.children.map((c, i) => this.renderNode(c, i))}
19+
</View>
20+
);
1621
}
1722

1823
renderElement(element, index) {
1924
if (this.ignoredTags.indexOf(element.name) > -1) {
2025
return null;
2126
}
2227
if (element.name === 'img') {
23-
return <Image key={index} source={{uri: element.attribs.src}} />;
28+
return <Image key={index} source={{ uri: element.attribs.src }} />;
2429
}
2530
const Wrapper = this.textTags.indexOf(element.name) > -1 ? Text : View;
2631
return (
@@ -40,13 +45,9 @@ export default class RenderHtmlSimple extends PureComponent {
4045
return null;
4146
}
4247

43-
render() {
44-
const {html, ...viewProps} = this.props;
45-
const document = parseDocument(html);
46-
return (
47-
<View {...viewProps}>
48-
{document.children.map((c, i) => this.renderNode(c, i))}
49-
</View>
50-
);
48+
renderTextNode(textNode, index) {
49+
return <Text key={index}>{textNode.data}</Text>;
5150
}
51+
52+
textTags = ['span', 'strong', 'em'];
5253
}

doc-tools/doc-docsusaurus-rfg-plugin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"build": "tsc -p ."
77
},
88
"dependencies": {
9-
"htmlparser2": "^6.1.0",
9+
"htmlparser2": "^7.1.1",
1010
"rfg-api": "^0.5.2"
1111
},
1212
"devDependencies": {

packages/render-html/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"@types/react-test-renderer": "^17.0.1",
5555
"babel-jest": "^27.0.2",
5656
"eslint": "^7.29.0",
57-
"htmlparser2": "^6.1.0",
57+
"htmlparser2": "^7.1.1",
5858
"jest": "^27.0.4",
5959
"metro-react-native-babel-preset": "^0.66.0",
6060
"prettier": "^2.3.1",

yarn.lock

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9958,7 +9958,7 @@ __metadata:
99589958
"@docusaurus/core": 2.0.0-beta.759298296
99599959
"@docusaurus/plugin-content-docs": 2.0.0-beta.759298296
99609960
"@docusaurus/types": 2.0.0-beta.759298296
9961-
htmlparser2: ^6.1.0
9961+
htmlparser2: ^7.1.1
99629962
rfg-api: ^0.5.2
99639963
typescript: ^4.3.2
99649964
languageName: unknown
@@ -12942,6 +12942,18 @@ fsevents@^1.2.7:
1294212942
languageName: node
1294312943
linkType: hard
1294412944

12945+
"htmlparser2@npm:^7.1.1":
12946+
version: 7.1.1
12947+
resolution: "htmlparser2@npm:7.1.1"
12948+
dependencies:
12949+
domelementtype: ^2.0.1
12950+
domhandler: ^4.0.0
12951+
domutils: ^2.8.0
12952+
entities: ^3.0.1
12953+
checksum: f0033544fd359615ad7433cacd5c3ed409590c47142fdd740e7256fa7978f6800662c4519ef9ced47cea13f4eb8df3eeea6c9c2793638a52e5faeaeb54b018c8
12954+
languageName: node
12955+
linkType: hard
12956+
1294512957
"http-cache-semantics@npm:^4.0.0, http-cache-semantics@npm:^4.1.0":
1294612958
version: 4.1.0
1294712959
resolution: "http-cache-semantics@npm:4.1.0"
@@ -19976,7 +19988,7 @@ fsevents@^1.2.7:
1997619988
"@types/urijs": ^1.19.15
1997719989
babel-jest: ^27.0.2
1997819990
eslint: ^7.29.0
19979-
htmlparser2: ^6.1.0
19991+
htmlparser2: ^7.1.1
1998019992
jest: ^27.0.4
1998119993
metro-react-native-babel-preset: ^0.66.0
1998219994
prettier: ^2.3.1

0 commit comments

Comments
 (0)