Skip to content

Commit

Permalink
DOM: Support class wildcard matcher in 'cleanNodeList' (#67830)
Browse files Browse the repository at this point in the history
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: ntsekouras <[email protected]>
  • Loading branch information
3 people authored Dec 16, 2024
1 parent bc4f6c6 commit 081a668
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/block-library/src/image/transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const schema = ( { phrasingContentSchema } ) => ( {
...imageSchema,
a: {
attributes: [ 'href', 'rel', 'target' ],
classes: [ /[\w-]*/ ],
classes: [ '*' ],
children: imageSchema,
},
figcaption: {
Expand Down
5 changes: 4 additions & 1 deletion packages/dom/src/dom/clean-node-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ export default function cleanNodeList( nodeList, doc, schema, inline ) {
// TODO: Explore patching this in jsdom-jscore.
if ( node.classList && node.classList.length ) {
const mattchers = classes.map( ( item ) => {
if ( typeof item === 'string' ) {
if ( item === '*' ) {
// Keep all classes.
return () => true;
} else if ( typeof item === 'string' ) {
return (
/** @type {string} */ className
) => className === item;
Expand Down

0 comments on commit 081a668

Please sign in to comment.