enfocus
enfocus copied to clipboard
get-prop doesn't work on data attributes
I'm working with the data attributes in HTML and found something which I think is a bug.
When getting a property which isn't :value
I get undefined
. Even though I used set-prop
to set the property. get-attr
works though.
I have used the following snippet on Firefox 25 and Chrome 31 on Linux (Fedora 20).
(ef/at ["form input[type=text]"]
(ev/listen :blur (fn [event]
(let [node (.-target event)]
(ef/at node (ef/set-prop :data-test "a string"))
(.log js/console (ef/from node (ef/get-prop :data-test)))
(.log js/console (ef/from node (ef/get-attr :data-test)))))))
The first console log outputs undefined
the second outputs a string
.
I will try to reproduce the issue. It certainly would be a bug if I can confirm. I don't see how get-attr is working at all though. Did the dom contain the attribute data-test also? Get prop is very very simple:
(defn get-prop
"returns the property on the selected element or elements.
in cases where more than one element is selected you will
receive a list of values"
[prop]
(extr-multi-node
(fn [pnod]
(aget pnod (name prop)))))