2013-04-24 76 views
0

如何擴展使用Clojurescript協議的Google Closure元素。我試過,但它似乎並沒有工作時:將Clojurescript協議添加到Google Closure元素

(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") 

:我必須做一些基本的錯誤,我認爲與ID元素「是」我的HTML頁面上永遠不會被更新。

回答

0

我工作得太晚,沒有發現丟失的 - (減號):

(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") 
相關問題