foundryvtt / pf2e

A community contributed game system for Pathfinder Second Edition.
https://foundryvtt.com/packages/pf2e
Apache License 2.0
391 stars 330 forks source link

System `sluggify` handling differs from JS property -> html attribute handling in the browser #15341

Closed esheyw closed 1 month ago

esheyw commented 1 month ago

This may or may not be a thing the system cares about, but it's something Idle noticed here: https://discord.com/channels/880968862240239708/880969304365994034/1258060472750702694

element.dataset.actionId = 'blah'
// produces <element data-action-id="blah">
const attrToFind = `data-${game.pf2e.system.sluggify('actionId')}`;
// produces "data-actionid"

Tested in Firefox 127 and Chrome 126

As I mention in discord this seems to be because the nonWordBoundry regex positive lookahead means it will never match the final character of a string by itself. Just adding |$ to the lookahead seems to make it match the browsers' behaviour: And I can't see how that would cause other incorrectness, but I'm not a regex master by any definition, so could easily be missing a nuance.

stwlam commented 1 month ago

ಠ_ಠ

reonZ commented 1 month ago

I wish my name wasn't associated with a shameless request !