Skip to content

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.

@rschristian rschristian changed the title fix: Serialize defaultChecked as checked attr fix: Serialize defaultChecked & defaultSelected Jul 6, 2022
@rschristian rschristian marked this pull request as draft July 6, 2022 16:46
@rschristian rschristian marked this pull request as ready for review July 6, 2022 16:58
@JoviDeCroock JoviDeCroock merged commit 645f3cb into master Jul 8, 2022
@JoviDeCroock JoviDeCroock deleted the fix/defaultChecked-attr branch July 8, 2022 10:06
@github-actions github-actions bot mentioned this pull request Jul 8, 2022
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

4 participants