You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importmatchHelperfrom"posthtml-match-helper";tree.match(matchHelper("div.class"),function(node){// do stuff with matched node...});
Advanced usage
importmatchHelperfrom"posthtml-match-helper";tree.match(matchHelper("input.my-control[type!='radio'][checked], input[value^='foo'][checked]"),function(node){// do stuff with node that matched either of the selectors...});
Classnames with escaped characters
If you need to match nodes with classnames that use escaped characters, like those in Tailwind CSS utilities with arbitrary values, use the following syntax:
importmatchHelperfrom"posthtml-match-helper";tree.match(matchHelper("input.\\[display:none\\]"),function(node){// do stuff with node that matched either of the selectors...});
The helper function
Arguments
matcher (string) - A CSS selector that describes the node you want to match in PostHTML.
Returns
A matcher object or an array of matcher objects.
About
A helper to expand CSS selectors into PostHTML matcher objects