kotlinx.html icon indicating copy to clipboard operation
kotlinx.html copied to clipboard

chrome warning Invalid DOM property `for`. Did you mean `htmlFor`

Open nailgilaziev opened this issue 6 years ago • 4 comments

this code snippet uses htmlFor but chrome throw error

            input(type = InputType.checkBox) {
                attrs.id = "showDeleted"
            }
            label {
                attrs.htmlFor = "showDeleted"
                +"Показать удаленные"
            }
2018-06-15 19 32 52

nailgilaziev avatar Jun 15 '18 16:06 nailgilaziev

What is attrs ? kotlinx.html itself does set attributes through setAttribute that will never warn about it

cy6erGn0m avatar Jun 25 '18 11:06 cy6erGn0m

Running into this same issue. The problem is this binding in kotlinx.html:

    var htmlFor : String
        get()  = attributeStringString.get(this, "for")
        set(newValue) {attributeStringString.set(this, "for", newValue)}

It binds "htmlFor" to "for"

weickmanna avatar Mar 14 '19 14:03 weickmanna

I tried to create a PR to fix this issue, but looking at the code, it says that the Kotlin file was "generated by module generate" and should not be edited. The generate module nowhere mentions the htmlFor attribute, so I wonder how var htmlFor : String even made it into this file ...

The general complication here is that the HTML attribute name does not match the JavaScript accessor name. The Kotlin wrappers are generated from an HTML5 XSD schema, which of course only contains the name of the HTML attribute. So a special case must be made to replace "for" with "htmlFor" in get-tags-l.kt. It seems that this special treatment has actually been done (how would var htmlFor: String otherwise get included into the file?), but it was done only half-way and I cannot see how it was done (was the file edited directly even though the comment says it should not be edited?).

weickmanna avatar Jun 19 '19 09:06 weickmanna

This is an issue with Kotlin React, not with kotlinx-html. I've opened https://github.com/JetBrains/kotlin-wrappers/issues/365 for that.

fluidsonic avatar Nov 08 '20 15:11 fluidsonic