BadgeAPI: fix

This commit is contained in:
Vendicated 2023-10-25 15:24:06 +02:00 committed by V
parent 44c9675795
commit 554bb18e9b

View file

@ -85,17 +85,19 @@ export default definePlugin({
}, },
{ {
// alt: "", aria-hidden: false, src: originalSrc // alt: "", aria-hidden: false, src: originalSrc
match: /alt:" ","aria-hidden":!0,src:(?=(\i)\.src)/g, match: /alt:" ","aria-hidden":!0,src:(?=(\i)\.src)/,
// ...badge.props, ..., src: badge.image ?? ... // ...badge.props, ..., src: badge.image ?? ...
replace: "...$1.props,$& $1.image??" replace: "...$1.props,$& $1.image??"
}, },
// replace their component with ours if applicable
{ {
match: /children:function(?<=(\i)\.(?:tooltip|description),spacing:\d.+?)/g, match: /(?<=text:(\i)\.description,spacing:12,)children:/,
replace: "children:$1.component ? () => $self.renderBadgeComponent($1) : function" replace: "children:$1.component ? () => $self.renderBadgeComponent($1) :"
}, },
// conditionally override their onClick with badge.onClick if it exists
{ {
match: /onClick:function(?=.{0,200}href:(\i)\.link)/, match: /href:(\i)\.link/,
replace: "onClick:$1.onClick??function" replace: "...($1.onClick && { onClick: $1.onClick }),$&"
} }
] ]
} }