Skip to content

Conversation

rschristian
Copy link
Member

Supports spellcheck={false} & removes support for spellCheck as we don't support it in Preact (see: preactjs/preact#3399)

Related: #388, denoland/fresh#2649, preactjs/preact#4497

This adds a HTML_ENUMERATED rgx to stuff enumerated true/false attributes into in the future, as I brought up in #388.

Copy link

changeset-bot bot commented Sep 14, 2024

🦋 Changeset detected

Latest commit: 6255591

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
preact-render-to-string Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@rschristian
Copy link
Member Author

Oh what the heck happened to the lockfile, will fix that later. Gotta get some food

src/lib/util.js Outdated
export const HTML_LOWER_CASE = /^accessK|^auto[A-Z]|^cell|^ch|^col|cont|cross|dateT|encT|form[A-Z]|frame|hrefL|inputM|maxL|minL|noV|playsI|popoverT|readO|rowS|spellC|src[A-Z]|tabI|useM|item[A-Z]/;
export const SVG_CAMEL_CASE = /^ac|^ali|arabic|basel|cap|clipPath$|clipRule$|color|dominant|enable|fill|flood|font|glyph[^R]|horiz|image|letter|lighting|marker[^WUH]|overline|panose|pointe|paint|rendering|shape|stop|strikethrough|stroke|spel|text[^L]|transform|underline|unicode|units|^v[^i]|^w|^xH/;
export const HTML_LOWER_CASE = /^accessK|^auto[A-Z]|^cell|^ch|^col|cont|cross|dateT|encT|form[A-Z]|frame|hrefL|inputM|maxL|minL|noV|playsI|popoverT|readO|rowS|src[A-Z]|tabI|useM|item[A-Z]/;
export const HTML_ENUMERATED = /^dra|spel/;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a set instead, performance wise this could help a lot

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, can do.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, what makes a set preferable here and not for the others? We certainly do make use of the patterns in a couple places, but that should just be byte saving, no?

There are certainly are a few more boolean props -> enumerated attrs, if it's the size of 2 that is what immediately concerns you, though I don't know quite how many there are. Will have to go hunting.

Copy link
Member

@JoviDeCroock JoviDeCroock Sep 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have undergone the efforts to port self-closing to a set but for the others I just don't know the amount of cases 😅

Also for style it's mainly keeping inline with Preact core because this regex is already lacking

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, thanks!

@rschristian rschristian force-pushed the fix/spellcheck-prop-serialization branch 2 times, most recently from eb7cc67 to 62ade27 Compare September 14, 2024 11:46
@rschristian rschristian merged commit ddf1bbb into main Sep 14, 2024
1 check passed
@rschristian rschristian deleted the fix/spellcheck-prop-serialization branch September 14, 2024 12:15
@github-actions github-actions bot mentioned this pull request Sep 14, 2024
@developit
Copy link
Member

developit commented Oct 2, 2024

looks like this may have regressed on the Text and SearchResults benchmarks:

RegexSet
Screenshot 2024-10-02 at 9 46 36 AM Screenshot 2024-10-02 at 9 46 40 AM

The fastest way to do this type of check would be an object with keys:

const HTML_ENUMERATED = { draggable: true, spellcheck: true }; // <snip> } else if ( (name[4] === '-' || name in HTML_ENUMERATED) && v != null ) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants