shadow-grove icon indicating copy to clipboard operation
shadow-grove copied to clipboard

Association of controls and forms

Open jacekschae opened this issue 1 year ago • 1 comments

In HTML it is possible to associate a [:button ...] to a [:form ...] element when the [:button ...] is outside of the [:form ...]. This requires specifying :id property on the [:form ...] and :form property on the [:button ...].

Spec: Association of controls and forms

Example:

[:form {:id "example-form"}
  [:input {:type "text" :name "full-name"}]]
[:input {:type "submit" :form "example-form"}]

In shadow-grove we are getting following error with the above setup:

TypeError: Cannot set property form of #<HTMLButtonElement> which has only a getter
    at Object.set (object.js:365:3)
    at eval (attributes.cljs:218:14)
    at Object.shadow$arborist$attributes$set_attr [as set_attr] (attributes.cljs:234:10)
    at Object.shadow$arborist$fragments$set_attr [as set_attr] (fragments.cljs:126:4)
    at Object.eval [as create_fn] (scripts.cljs:273:17)
    at Object.eval [as shadow$arborist$protocols$IConstruct$as_managed$arity$2] (fragments.cljs:95:23)
    at Object.shadow$arborist$protocols$as_managed [as as_managed] (protocols.cljs:26:16)
    at Object.eval [as shadow$arborist$protocols$IDirectUpdate$update_BANG_$arity$2] (common.cljs:103:17)
    at eval (portal.cljs:36:7)
    at Object.eval [as shadow$arborist$protocols$IConstruct$as_managed$arity$2] (portal.cljs:36:7)

jacekschae avatar Aug 20 '22 19:08 jacekschae

I'm getting a similar/same error for

[:input {:type "text" :list "mm"}]
[:datalist#mm [:option "apple"] [:option "banana"]]

on the list attribute/property.

TypeError: Cannot set property list of #<HTMLInputElement> which has only a getter
    at Object.set (object.js:365:3)
    at eval (attributes.cljs:218:14)
    at Object.shadow$arborist$attributes$set_attr [as set_attr] (attributes.cljs:234:10)
    at Object.shadow$arborist$fragments$set_attr [as set_attr] (fragments.cljs:135:4)
    at Object.eval [as create_fn] (components.cljs:412:15)
    at new shadow$arborist$fragments$ManagedFragment (fragments.cljs:66:25)
    at Object.eval [as shadow$arborist$protocols$IConstruct$as_managed$arity$2] (fragments.cljs:105:5)
    at Object.shadow$arborist$protocols$as_managed [as as_managed] (protocols.cljs:26:16)
    at Object.eval [as shadow$arborist$protocols$IDirectUpdate$update_BANG_$arity$2] (common.cljs:103:17)
    at Object.shadow$arborist$protocols$update_BANG_ [as update_BANG_] (protocols.cljs:22:13)

Using set-dom-attribute instead of gobj/set at https://github.com/thheller/shadow-grove/blob/695fd0b26e4798370a18f2b7ff0e9f1daadac5d1/src/main/shadow/arborist/attributes.cljs#L218 solves it.

zeitstein avatar Oct 06 '22 12:10 zeitstein