File tree Expand file tree Collapse file tree 5 files changed +27
-40
lines changed Expand file tree Collapse file tree 5 files changed +27
-40
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,12 @@ Parser('<p>Hello, world!</p>');
33
33
$ npm install html-react-parser
34
34
```
35
35
36
+ Or if you're using react <15.4:
37
+
38
+ ``` sh
39
+ $ npm install html-react-parser@0.2
40
+ ```
41
+
36
42
[ CDN] ( https://unpkg.com/html-react-parser/ ) :
37
43
38
44
``` html
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 3
3
/**
4
4
* Module dependencies.
5
5
*/
6
- var HTMLDOMPropertyConfig = require ( './DOMPropertyConfig' ) . HTMLDOMPropertyConfig ;
7
6
var utilities = require ( './utilities' ) ;
8
7
var propertyConfig = require ( './property-config' ) ;
8
+ var config = propertyConfig . config ;
9
+ var isCustomAttribute = propertyConfig . HTMLDOMPropertyConfig . isCustomAttribute ;
9
10
10
11
/**
11
12
* Make attributes compatible with React props.
@@ -24,20 +25,20 @@ function attributesToProps(attributes) {
24
25
propertyValue = attributes [ propertyName ] ;
25
26
26
27
// custom attributes (`data-` and `aria-`)
27
- if ( HTMLDOMPropertyConfig . isCustomAttribute ( propertyName ) ) {
28
+ if ( isCustomAttribute ( propertyName ) ) {
28
29
props [ propertyName ] = propertyValue ;
29
30
continue ;
30
31
}
31
32
32
33
// make HTML DOM attribute/property consistent with React attribute/property
33
- reactProperty = propertyConfig . html [ propertyName . toLowerCase ( ) ] ;
34
+ reactProperty = config . html [ propertyName . toLowerCase ( ) ] ;
34
35
if ( reactProperty ) {
35
36
props [ reactProperty ] = propertyValue ;
36
37
continue ;
37
38
}
38
39
39
40
// make SVG DOM attribute/property consistent with React attribute/property
40
- reactProperty = propertyConfig . svg [ propertyName ] ;
41
+ reactProperty = config . svg [ propertyName ] ;
41
42
if ( reactProperty ) {
42
43
props [ reactProperty ] = propertyValue ;
43
44
}
Original file line number Diff line number Diff line change 4
4
* Module dependencies.
5
5
*/
6
6
var utilities = require ( './utilities' ) ;
7
- var DOMPropertyConfig = require ( './DOMPropertyConfig' ) ;
8
- var HTMLDOMPropertyConfig = DOMPropertyConfig . HTMLDOMPropertyConfig ;
9
- var SVGDOMPropertyConfig = DOMPropertyConfig . SVGDOMPropertyConfig ;
7
+
8
+ // HTML and SVG DOM Property Configs
9
+ var HTMLDOMPropertyConfig = require ( 'react/lib/HTMLDOMPropertyConfig' ) ;
10
+ var SVGDOMPropertyConfig = require ( 'react/lib/SVGDOMPropertyConfig' ) ;
10
11
11
12
var config = {
12
13
html : { } ,
@@ -54,6 +55,10 @@ for (propertyName in SVGDOMPropertyConfig.Properties) {
54
55
}
55
56
56
57
/**
57
- * Export React property config .
58
+ * Export React property configs .
58
59
*/
59
- module . exports = config ;
60
+ module . exports = {
61
+ config : config ,
62
+ HTMLDOMPropertyConfig : HTMLDOMPropertyConfig ,
63
+ SVGDOMPropertyConfig : SVGDOMPropertyConfig
64
+ } ;
Original file line number Diff line number Diff line change 5
5
"author" : " Mark <mark@remarkablemark.org>" ,
6
6
"main" : " index.js" ,
7
7
"scripts" : {
8
- "build" : " NODE_ENV=development webpack index.js dist/html-react-parser.js" ,
8
+ "build-unmin " : " NODE_ENV=development webpack index.js dist/html-react-parser.js" ,
9
9
"build-min" : " NODE_ENV=production webpack -p index.js dist/html-react-parser.min.js" ,
10
- "prepublish" : " npm run build && npm run build-min" ,
10
+ "clean" : " rm -rf dist" ,
11
+ "prepublish" : " npm run clean && npm run build-unmin && npm run build-min" ,
11
12
"test" : " mocha" ,
12
13
"lint" : " eslint index.js \" lib/**\" \" test/**\" " ,
13
14
"cover" : " istanbul cover _mocha -- -R spec \" test/**/*\" " ,
36
37
"istanbul" : " ^0.4.5" ,
37
38
"jsdomify" : " ^2.1.0" ,
38
39
"mocha" : " ^3.0.2" ,
39
- "react" : " * " ,
40
- "react-dom" : " * " ,
40
+ "react" : " 15.3 " ,
41
+ "react-dom" : " 15.3 " ,
41
42
"webpack" : " ^1.13.2"
42
43
},
43
44
"peerDependencies" : {
44
- "react" : " >=0.14 "
45
+ "react" : " <=15.3 "
45
46
},
46
47
"browser" : {
47
- "./lib/html-to-dom-server.js" : false ,
48
48
"htmlparser2/lib/Parser" : false ,
49
49
"domhandler" : false
50
50
},
You can’t perform that action at this time.
0 commit comments