Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Serialize defaultChecked & defaultSelected #224

Merged
merged 3 commits into from
Jul 8, 2022

Conversation

rschristian
Copy link
Member

Closes #223

Not sure if there are any other defaultX props to be concerned with (my memory and MDN are failing me). I think every other check / replace method would be a fair bit slower, so I imagine while limited to these two (defaultValue and defaultChecked) this approach is better? LMK!

@changeset-bot
Copy link

changeset-bot bot commented Jun 16, 2022

🦋 Changeset detected

Latest commit: d4e2386

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

Comment on lines -269 to +271
} else if (isSvgMode && name.match(/^xlink:?./)) {
} else if (isSvgMode && /^xlink:?./.test(name)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Unrelated (sorry!) but .test() should be marginally faster.

@alvinleung1996
Copy link

There is also a defaultSelected property for the option element.

https://html.spec.whatwg.org/multipage/form-elements.html#dom-option-defaultselected

@JoviDeCroock
Copy link
Member

@rschristian do you want this merged already? Wanted to do a small release for the perf improvements

@rschristian
Copy link
Member Author

rschristian commented Jul 6, 2022

@JoviDeCroock Sorry, must've missed or forgotten about this. Added in defaultSelected, so should probably be good unless you have suggestions or changes.

Edit: Actually .replace might be faster? Gonna poke at this real quick, the if else ain't exactly pretty and while I assumed it's faster, I might be wrong.

Double Edit: Nope, my benchmark had issues. I was right the first time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attribute defaultChecked should be outputted as checked instead of defaultChecked
3 participants