Skip to content

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

Open
@nolanlawson

Description

@nolanlawson

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)
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions