Skip to content

Instantly share code, notes, and snippets.

@whilo
Created July 5, 2013 22:44
Show Gist options
  • Save whilo/5937694 to your computer and use it in GitHub Desktop.
Save whilo/5937694 to your computer and use it in GitHub Desktop.
Trying to extend protocol to native javascript DOM type with ClojureScript.
(defprotocol PWindow
(parent [this])
(position [this])
(size [this]))
(extend-protocol PWindow
js/HTMLDivElement
(parent [this] (.-parentNode this))
(position [this] {:top (.-clientTop this) :left (.-clientLeft this)})
(size [this] {:width (.-clientWidth this) :height (.-clientHeight this)}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment