fix(runtime): unwrap surrogates before writing DOM properties - #260
Open
SixSeven-Labs wants to merge 1 commit into
Open
fix(runtime): unwrap surrogates before writing DOM properties#260SixSeven-Labs wants to merge 1 commit into
SixSeven-Labs wants to merge 1 commit into
Conversation
value, checked, selected and indeterminate are written as properties rather than attributes, but the computed value went over as-is. A surrogate is an object and every object is truthy, so Bool(false) landed on checked as a truthy object and the box rendered checked whatever the expression said. value got away with it: assigning an object stringifies through toString, which for Str happens to be the text we wanted anyway.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ran into this building a little catalog browser on 0.5.0. two checkboxes bound with
:checkedtofalsesignals, both came up checked.binding.tswrites value/checked/selected/indeterminate as properties instead of attributes, which is right, but it hands the computed value straight over:that value is a surrogate. objects are truthy, so
el.checked = Bool(false)checks the box. and the attribute path right below it does the correct thing and calls removeAttribute, so devtools shows nocheckedattribute while the property disagrees. took me a minute to find.valuegets away with it by accident. assigning an object goes through toString, andStr.toStringhands back the string we wanted anyway.fix moves the unwrap into
propertyValue(name, value). boolean props readisAttributePresent(),valuereadstoAttributeValue(), or""when the value is absent sinceNone.toAttributeValue()throws. non surrogate values pass through, coerced to bool for the boolean props soraw!keeps working.checked against
examples/runtimewith a few extra inputs on the show page, whereoffis:checked=$(show.get())and show starts false:test is a unit test on
propertyValue, no dom needed. dist rebuilt withnpm run build.