Skip to content

Commit

Permalink
Fix odd usage of transform-styles wrap function. (#23599)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZebulanStanphill committed Oct 13, 2021
1 parent d79e67c commit 6835e66
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe( 'CSS selector wrap', () => {
} );

it( 'should ignore selectors', () => {
const callback = wrap( '.my-namespace', 'body' );
const callback = wrap( '.my-namespace', [ 'body' ] );
const input = `h1, body { color: red; }`;
const output = traverse( input, callback );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,23 @@
*/
const IS_ROOT_TAG = /^(body|html|:root).*$/;

/**
* Creates a callback to modify selectors so they only apply within a certain
* namespace.
*
* @param {string} namespace Namespace to prefix selectors with.
* @param {string[]} ignore Selectors to not prefix.
*
* @return {(node: Object) => Object} Callback to wrap selectors.
*/
const wrap = ( namespace, ignore = [] ) => ( node ) => {
/**
* Updates selector if necessary.
*
* @param {string} selector Selector to modify.
*
* @return {string} Updated selector.
*/
const updateSelector = ( selector ) => {
if ( ignore.includes( selector.trim() ) ) {
return selector;
Expand Down

0 comments on commit 6835e66

Please sign in to comment.