diff --git a/lib/ast-to-react.js b/lib/ast-to-react.js index 5248e5e1..ef02544e 100644 --- a/lib/ast-to-react.js +++ b/lib/ast-to-react.js @@ -42,14 +42,6 @@ * @param {string?} title * @returns {string} * - * @typedef {import('react').HTMLAttributeAnchorTarget} TransformLinkTargetType - * - * @callback TransformLinkTarget - * @param {string} href - * @param {Array} children - * @param {string?} title - * @returns {TransformLinkTargetType|undefined} - * * @typedef {keyof JSX.IntrinsicElements} ReactMarkdownNames * * To do: is `data-sourcepos` typeable? @@ -96,7 +88,6 @@ * @property {boolean} [includeElementIndex=false] * @property {null|false|TransformLink} [transformLinkUri] * @property {TransformImage} [transformImageUri] - * @property {TransformLinkTargetType|TransformLinkTarget} [linkTarget] * @property {Components} [components] */ @@ -223,17 +214,6 @@ function toReact(context, node, index, parent) { properties.key = index - if (name === 'a' && options.linkTarget) { - properties.target = - typeof options.linkTarget === 'function' - ? options.linkTarget( - String(properties.href || ''), - node.children, - typeof properties.title === 'string' ? properties.title : null - ) - : options.linkTarget - } - if (name === 'a' && transform) { properties.href = transform( String(properties.href || ''), diff --git a/lib/react-markdown.js b/lib/react-markdown.js index 92a032c7..df97b321 100644 --- a/lib/react-markdown.js +++ b/lib/react-markdown.js @@ -178,7 +178,6 @@ ReactMarkdown.propTypes = { skipHtml: PropTypes.bool, includeElementIndex: PropTypes.bool, transformLinkUri: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]), - linkTarget: PropTypes.oneOfType([PropTypes.func, PropTypes.string]), transformImageUri: PropTypes.func, components: PropTypes.object } diff --git a/readme.md b/readme.md index 2b00a70e..30be3fdc 100644 --- a/readme.md +++ b/readme.md @@ -203,8 +203,6 @@ The default export is `ReactMarkdown`. extract (unwrap) the children of not allowed elements, by default, when `strong` is disallowed, it and it’s children are dropped, but with `unwrapDisallowed` the element itself is replaced by its children -* `linkTarget` (`string` or `(href, children, title) => string`, optional)\ - target to use on links (such as `_blank` for ` string`, default: [`uriTransformer`][uri-transformer], optional)\ change URLs on links, pass `null` to allow all URLs, see [security][] @@ -632,8 +630,6 @@ Optionally, components will also receive: — see `rawSourcePos` option * `index` and `siblingCount` (`number`) — see `includeElementIndex` option -* `target` on `a` (`string`) - — see `linkTarget` option ## Security diff --git a/test/test.jsx b/test/test.jsx index aef80589..ed0418f3 100644 --- a/test/test.jsx +++ b/test/test.jsx @@ -231,62 +231,6 @@ test('should handle titles of links', () => { assert.equal(actual, '

Empty:

') }) -test('should use target attribute for links if specified', () => { - const input = 'This is [a link](https://espen.codes/) to Espen.Codes.' - const actual = asHtml() - assert.equal( - actual, - '

This is a link to Espen.Codes.

' - ) -}) - -test('should call function to get target attribute for links if specified', () => { - const input = 'This is [a link](https://espen.codes/) to Espen.Codes.' - const actual = asHtml( - (uri.startsWith('http') ? '_blank' : undefined)} - /> - ) - assert.equal( - actual, - '

This is a link to Espen.Codes.

' - ) -}) - -test('should handle links with custom target transformer', () => { - const input = 'Empty: []()' - - const actual = asHtml( - { - assert.equal(uri, '', '`uri` should be an empty string') - assert.equal(title, null, '`title` should be null') - return undefined - }} - /> - ) - - assert.equal(actual, '

Empty:

') -}) - -test('should handle links w/ titles with custom target transformer', () => { - const input = 'Empty: [](a "b")' - - const actual = asHtml( - { - assert.equal(title, 'b', '`title` should be given') - return undefined - }} - /> - ) - - assert.equal(actual, '

Empty:

') -}) - test('should support images without alt, url, or title', () => { const input = '![]()' const actual = asHtml()