Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ Parser('<p>Hello, world!</p>');
$ npm install html-react-parser
```

Or if you're using react <15.4:

```sh
$ npm install html-react-parser@0.2
```

[CDN](https://unpkg.com/html-react-parser/):

```html
Expand Down
25 changes: 0 additions & 25 deletions lib/DOMPropertyConfig.js

This file was deleted.

9 changes: 5 additions & 4 deletions lib/attributes-to-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
/**
* Module dependencies.
*/
var HTMLDOMPropertyConfig = require('./DOMPropertyConfig').HTMLDOMPropertyConfig;
var utilities = require('./utilities');
var propertyConfig = require('./property-config');
var config = propertyConfig.config;
var isCustomAttribute = propertyConfig.HTMLDOMPropertyConfig.isCustomAttribute;

/**
* Make attributes compatible with React props.
Expand All @@ -24,20 +25,20 @@ function attributesToProps(attributes) {
propertyValue = attributes[propertyName];

// custom attributes (`data-` and `aria-`)
if (HTMLDOMPropertyConfig.isCustomAttribute(propertyName)) {
if (isCustomAttribute(propertyName)) {
props[propertyName] = propertyValue;
continue;
}

// make HTML DOM attribute/property consistent with React attribute/property
reactProperty = propertyConfig.html[propertyName.toLowerCase()];
reactProperty = config.html[propertyName.toLowerCase()];
if (reactProperty) {
props[reactProperty] = propertyValue;
continue;
}

// make SVG DOM attribute/property consistent with React attribute/property
reactProperty = propertyConfig.svg[propertyName];
reactProperty = config.svg[propertyName];
if (reactProperty) {
props[reactProperty] = propertyValue;
}
Expand Down
15 changes: 10 additions & 5 deletions lib/property-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
* Module dependencies.
*/
var utilities = require('./utilities');
var DOMPropertyConfig = require('./DOMPropertyConfig');
var HTMLDOMPropertyConfig = DOMPropertyConfig.HTMLDOMPropertyConfig;
var SVGDOMPropertyConfig = DOMPropertyConfig.SVGDOMPropertyConfig;

// HTML and SVG DOM Property Configs
var HTMLDOMPropertyConfig = require('react/lib/HTMLDOMPropertyConfig');
var SVGDOMPropertyConfig = require('react/lib/SVGDOMPropertyConfig');

var config = {
html: {},
Expand Down Expand Up @@ -54,6 +55,10 @@ for (propertyName in SVGDOMPropertyConfig.Properties) {
}

/**
* Export React property config.
* Export React property configs.
*/
module.exports = config;
module.exports = {
config: config,
HTMLDOMPropertyConfig: HTMLDOMPropertyConfig,
SVGDOMPropertyConfig: SVGDOMPropertyConfig
};
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
"author": "Mark <mark@remarkablemark.org>",
"main": "index.js",
"scripts": {
"build": "NODE_ENV=development webpack index.js dist/html-react-parser.js",
"build-unmin": "NODE_ENV=development webpack index.js dist/html-react-parser.js",
"build-min": "NODE_ENV=production webpack -p index.js dist/html-react-parser.min.js",
"prepublish": "npm run build && npm run build-min",
"clean": "rm -rf dist",
"prepublish": "npm run clean && npm run build-unmin && npm run build-min",
"test": "mocha",
"lint": "eslint index.js \"lib/**\" \"test/**\"",
"cover": "istanbul cover _mocha -- -R spec \"test/**/*\"",
Expand Down Expand Up @@ -36,15 +37,14 @@
"istanbul": "^0.4.5",
"jsdomify": "^2.1.0",
"mocha": "^3.0.2",
"react": "*",
"react-dom": "*",
"react": "15.3",
"react-dom": "15.3",
"webpack": "^1.13.2"
},
"peerDependencies": {
"react": ">=0.14"
"react": "<=15.3"
},
"browser": {
"./lib/html-to-dom-server.js": false,
"htmlparser2/lib/Parser": false,
"domhandler": false
},
Expand Down