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

[SSR/template-compiler] Align draggable with spellcheck [potentially breaking] #4870

Open
Tracked by #2964
nolanlawson opened this issue Nov 14, 2024 · 0 comments
Open
Tracked by #2964

Comments

@nolanlawson
Copy link
Collaborator

Currently we do a lot of special munging for the spellcheck attribute:

// `spellcheck` string values are specially handled to massage them into booleans.
if (attrName === 'spellcheck') {
return t.literal(attrValue.value.toLowerCase() !== 'false');
}

Arguably we should do the same thing for draggable since, in terms of IDL reflection, it works the same as spellcheck but with a different default:

const div = document.createElement('div')
div.spellcheck // true
div.draggable // false

Table of setAttribute values and what you get from the property afterwards:

spellcheck:

Value Result
"" true
"false" false
"true" true
"FALSE" false
"TRUE" true
"yolo" true

draggable:

Value Result
"" false
"false" false
"true" true
"FALSE" false
"TRUE" true
"yolo" false

Test script:

function test(name) {
    const results = []
    for (const value of ['', 'false', 'true', 'FALSE', 'TRUE', 'yolo']) {
        div.setAttribute(name, value)
        results[JSON.stringify(value)] = div[name]
    }
    console.table(results)
}
@nolanlawson nolanlawson changed the title Align draggable with spellcheck [SSR/template-compiler] Align draggable with spellcheck Nov 14, 2024
@nolanlawson nolanlawson changed the title [SSR/template-compiler] Align draggable with spellcheck [SSR/template-compiler] Align draggable with spellcheck [potentially breaking] Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant