Skip to content

Commit aaaa40b

Browse files
wooormremcohaszing
andcommitted
Remove support for className prop
ClosesGH-781. ClosesGH-799. Reviewed-by: Christian Murphy <christian.murphy.42@gmail.com> Co-authored-by: Remco Haszing <remcohaszing@gmail.com>
1 parent 747e505 commit aaaa40b

3 files changed

Lines changed: 2 additions & 42 deletions

File tree

‎lib/index.js‎

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @import {Element, ElementContent, Nodes, Parents, Root} from 'hast'
2+
* @import {Element, Nodes, Parents, Root} from 'hast'
33
* @import {Root as MdastRoot} from 'mdast'
44
* @import {ComponentProps, ElementType, ReactElement} from 'react'
55
* @import {Options as RemarkRehypeOptions} from 'remark-rehype'
@@ -127,6 +127,7 @@ const deprecations = [
127127
id: 'replace-allownode-allowedtypes-and-disallowedtypes',
128128
to: 'allowedElements'
129129
},
130+
{from: 'className',id: 'deprecate-classname'},
130131
{
131132
from: 'disallowedTypes',
132133
id: 'replace-allownode-allowedtypes-and-disallowedtypes',
@@ -322,19 +323,6 @@ function post(tree, options) {
322323
)
323324
}
324325

325-
// Wrap in `div` if there’s a class name.
326-
if(options.className){
327-
tree={
328-
type: 'element',
329-
tagName: 'div',
330-
properties: {className: options.className},
331-
// Assume no doctypes.
332-
children: /** @type {Array<ElementContent>} */(
333-
tree.type==='root' ? tree.children : [tree]
334-
)
335-
}
336-
}
337-
338326
visit(tree,transform)
339327

340328
returntoJsxRuntime(tree,{

‎readme.md‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,6 @@ Configuration (TypeScript type).
302302
cannot combine w/ `disallowedElements`
303303
* `children` (`string`, optional)
304304
— markdown
305-
* `className` (`string`, optional)
306-
— wrap in a `div` with this class name
307305
* `components` ([`Components`][api-components], optional)
308306
— map tag names to components
309307
* `disallowedElements` (`Array<string>`, default: `[]`)

‎test.jsx‎

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -70,32 +70,6 @@ test('Markdown', async function (t) {
7070
},/Unexpected`allowDangerousHtml`prop,removeit/)
7171
})
7272

73-
awaitt.test('should support `className`',function(){
74-
assert.equal(
75-
renderToStaticMarkup(<Markdownchildren="a"className="md"/>),
76-
'<div class="md"><p>a</p></div>'
77-
)
78-
})
79-
80-
awaitt.test('should support `className` (if w/o root)',function(){
81-
assert.equal(
82-
renderToStaticMarkup(
83-
<Markdownchildren={'a'}className="b"rehypePlugins={[plugin]}/>
84-
),
85-
'<div class="b"></div>'
86-
)
87-
88-
functionplugin(){
89-
/**
90-
* @returns {Root}
91-
*/
92-
returnfunction(){
93-
// @ts-expect-error: check how non-roots are handled.
94-
return{type: 'comment',value: 'things!'}
95-
}
96-
}
97-
})
98-
9973
awaitt.test('should support a block quote',function(){
10074
assert.equal(
10175
renderToStaticMarkup(<Markdownchildren="> a"/>),

0 commit comments

Comments
 (0)