0
votes

How can i extend a Google Closure element using Clojurescript protocols. I tried this but it doesn't seem to work:

(ns my-stuff.main
    (:require
      [goog.dom :as dom))

 (defprotocol ds 
      (-set-text [this text]))

(extend-type js/HTMLDivElement
  ds
  (-set-text
    [this text]  (dom/setTextContent this text)))


(set-text (.getElementById js/document "a") "howdy")

: I must be doing something basic wrong I think as the element with ID "a" on my HTML page never gets updated.

1

1 Answers

0
votes

I was working too late and didn't spot the missing - (minus sign):

(ns my-stuff.main
    (:require
      [goog.dom :as dom))

 (defprotocol ds 
      (-set-text [this text]))

(extend-type js/HTMLDivElement
  ds
  (-set-text
    [this text]  (dom/setTextContent this text)))


(-set-text (.getElementById js/document "a") "howdy")