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>');
3333$ npm install html-react-parser
3434```
3535
36+ Or if you're using react <15.4:
37+
38+ ``` sh
39+ $ npm install html-react-parser@0.2
40+ ```
41+
3642[ CDN] ( https://unpkg.com/html-react-parser/ ) :
3743
3844``` html
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 33/**
44 * Module dependencies.
55 */
6- var HTMLDOMPropertyConfig = require ( './DOMPropertyConfig' ) . HTMLDOMPropertyConfig ;
76var utilities = require ( './utilities' ) ;
87var propertyConfig = require ( './property-config' ) ;
8+ var config = propertyConfig . config ;
9+ var isCustomAttribute = propertyConfig . HTMLDOMPropertyConfig . isCustomAttribute ;
910
1011/**
1112 * Make attributes compatible with React props.
@@ -24,20 +25,20 @@ function attributesToProps(attributes) {
2425 propertyValue = attributes [ propertyName ] ;
2526
2627 // custom attributes (`data-` and `aria-`)
27- if ( HTMLDOMPropertyConfig . isCustomAttribute ( propertyName ) ) {
28+ if ( isCustomAttribute ( propertyName ) ) {
2829 props [ propertyName ] = propertyValue ;
2930 continue ;
3031 }
3132
3233 // make HTML DOM attribute/property consistent with React attribute/property
33- reactProperty = propertyConfig . html [ propertyName . toLowerCase ( ) ] ;
34+ reactProperty = config . html [ propertyName . toLowerCase ( ) ] ;
3435 if ( reactProperty ) {
3536 props [ reactProperty ] = propertyValue ;
3637 continue ;
3738 }
3839
3940 // make SVG DOM attribute/property consistent with React attribute/property
40- reactProperty = propertyConfig . svg [ propertyName ] ;
41+ reactProperty = config . svg [ propertyName ] ;
4142 if ( reactProperty ) {
4243 props [ reactProperty ] = propertyValue ;
4344 }
Original file line number Diff line number Diff line change 44 * Module dependencies.
55 */
66var 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' ) ;
1011
1112var config = {
1213 html : { } ,
@@ -54,6 +55,10 @@ for (propertyName in SVGDOMPropertyConfig.Properties) {
5455}
5556
5657/**
57- * Export React property config .
58+ * Export React property configs .
5859 */
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 55 "author" : " Mark <mark@remarkablemark.org>" ,
66 "main" : " index.js" ,
77 "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" ,
99 "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" ,
1112 "test" : " mocha" ,
1213 "lint" : " eslint index.js \" lib/**\" \" test/**\" " ,
1314 "cover" : " istanbul cover _mocha -- -R spec \" test/**/*\" " ,
3637 "istanbul" : " ^0.4.5" ,
3738 "jsdomify" : " ^2.1.0" ,
3839 "mocha" : " ^3.0.2" ,
39- "react" : " * " ,
40- "react-dom" : " * " ,
40+ "react" : " 15.3 " ,
41+ "react-dom" : " 15.3 " ,
4142 "webpack" : " ^1.13.2"
4243 },
4344 "peerDependencies" : {
44- "react" : " >=0.14 "
45+ "react" : " <=15.3 "
4546 },
4647 "browser" : {
47- "./lib/html-to-dom-server.js" : false ,
4848 "htmlparser2/lib/Parser" : false ,
4949 "domhandler" : false
5050 },
You can’t perform that action at this time.
0 commit comments