Created
July 5, 2013 22:44
-
-
Save whilo/5937694 to your computer and use it in GitHub Desktop.
Trying to extend protocol to native javascript DOM type with ClojureScript.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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