diff --git a/index.js b/index.js index f25a437..3657667 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,7 @@ /* Dependencies. */ var has = require('has'); var toH = require('hast-to-hyperscript'); +var tableCellStyle = require('@mapbox/hast-util-table-cell-style'); /* Expose `rehype-react`. */ module.exports = rehype2react; @@ -41,7 +42,7 @@ function rehype2react(options) { } } - return toH(h, node, settings.prefix); + return toH(h, tableCellStyle(node), settings.prefix); } /* Wrap `createElement` to pass components in. */ diff --git a/package.json b/package.json index 757496a..5962f79 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "rhysd " ], "dependencies": { + "@mapbox/hast-util-table-cell-style": "^0.1.3", "has": "^1.0.1", "hast-to-hyperscript": "^5.0.0" }, diff --git a/test.js b/test.js index af4211d..4c16c94 100644 --- a/test.js +++ b/test.js @@ -108,5 +108,15 @@ test('React ' + React.version, function (t) { 'should support components' ); + t.deepEqual( + processor.stringify(h('table', {}, [h('thead', h('th', {align: 'right'}))])), + React.createElement('table', {key: 'h-1'}, [ + React.createElement('thead', {key: 'h-2'}, [ + React.createElement('th', {style: {textAlign: 'right'}, key: 'h-3'}, undefined) + ]) + ]), + 'should transform an element with align property' + ); + t.end(); });