From 8f95f67a2c6625101d4fc94d6e5273ac890182b8 Mon Sep 17 00:00:00 2001 From: Jonn Mostovoy Date: Sat, 22 Aug 2015 04:33:49 +0200 Subject: [PATCH] Add getAttribute and setAttribute --- src/DOM/Node/Element.js | 19 +++++++++++++++++++ src/DOM/Node/Element.purs | 3 +++ 2 files changed, 22 insertions(+) diff --git a/src/DOM/Node/Element.js b/src/DOM/Node/Element.js index b2ef356..9d4e3cf 100644 --- a/src/DOM/Node/Element.js +++ b/src/DOM/Node/Element.js @@ -69,3 +69,22 @@ exports.getElementsByClassName = function (classNames) { }; }; }; + +exports.setAttribute = function (name) { + return function (value) { + return function (element) { + return function () { + element.setAttribute(name, value); + return {}; + }; + }; + }; +}; + +exports.getAttribute = function (name) { + return function (element) { + return function () { + return element.getAttribute(name); + }; + }; +}; diff --git a/src/DOM/Node/Element.purs b/src/DOM/Node/Element.purs index f68f7e2..a8ff382 100644 --- a/src/DOM/Node/Element.purs +++ b/src/DOM/Node/Element.purs @@ -20,3 +20,6 @@ foreign import setClassName :: forall eff. String -> Element -> Eff (dom :: DOM foreign import getElementsByTagName :: forall eff. String -> Element -> Eff (dom :: DOM | eff) HTMLCollection foreign import getElementsByTagNameNS :: forall eff. Nullable String -> String -> Element -> Eff (dom :: DOM | eff) HTMLCollection foreign import getElementsByClassName :: forall eff. String -> Element -> Eff (dom :: DOM | eff) HTMLCollection + +foreign import setAttribute :: forall eff. String -> String -> Element -> Eff (dom :: DOM | eff) String +foreign import getAttribute :: forall eff. String -> Element -> Eff (dom :: DOM | eff) (Nullable String)