diff --git a/CHANGELOG.md b/CHANGELOG.md index a76978b..d270aa7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ Notable changes to this project are documented in this file. The format is based ## [Unreleased] +Breaking changes: + +New features: + +Bugfixes: + +Other improvements: + +## [v7.0.0](https://github.com/purescript-web/purescript-web-dom/releases/tag/v7.0.0) - 2024-11-06 + Breaking changes: - The `id` function returns an `ElementId` instead of a `String`. (#58 by @nsaunders) - The `setId` function is parameterized by `ElementId` instead of `String`. (#58 by @nsaunders) @@ -13,12 +23,10 @@ Breaking changes: - The `getAttribute`, `setAttribute`, `hasAttribute`, and `removeAttribute` functions are parameterized by `AttrName` instead of `String`. (#58 by @nsaunders) New features: -- `AttrName`, `ClassName`, and `PropName` types have been added, migrated from [web-html](https://github.com/purescript-web/purescript-web-html). (#58 by @nsaunders) -- A new `ElementId` type, representing the value of an `id` property/attribute, has been added. (#58 by @nsaunders) - -Bugfixes: - -Other improvements: +- Added modules `NamedNodeMap`, `Attr` and `DOMTokenList` (#59 by @flip111) +- Added types `AttrName`, `AttrLocalName`, `ClassName`, and `PropName`, migrated from [web-html](https://github.com/purescript-web/purescript-web-html). (#58 by @nsaunders) +- Added type `ElementId`, representing the value of an `id` property/attribute. (#58 by @nsaunders) +- Added types `CompatMode`, `ElementName`, `NamespacePrefix` and `NamespaceURI` (#59 by @garyb) ## [v6.0.0](https://github.com/purescript-web/purescript-web-dom/releases/tag/v6.0.0) - 2022-04-27 @@ -27,12 +35,6 @@ Breaking changes: - Unwrap returned `Effect` for `doctype` (#52 by @JordanMartinez) - Port `getBoundingClientRect` from `web-html`; set arg to `Element` (#53 by @JordanMartinez) -New features: - -Bugfixes: - -Other improvements: - ## [v5.0.0](https://github.com/purescript-web/purescript-web-dom/releases/tag/v5.0.0) - 2021-02-26 Breaking changes: @@ -43,8 +45,6 @@ New features: - Add support for ShadowRoot API (#34) - Add support for `Element.matches` and `Element.closest` (#39) -Bugfixes: - Other improvements: - Migrated CI to GitHub Actions and updated installation instructions to use Spago (#28, #30) - Added a CHANGELOG.md file and updated pull request template (#35, #36, #37) diff --git a/src/Web/DOM/Attr.js b/src/Web/DOM/Attr.js index 0a60b69..331144b 100644 --- a/src/Web/DOM/Attr.js +++ b/src/Web/DOM/Attr.js @@ -4,6 +4,8 @@ export const _prefix = (attr) => attr.prefix; export const localName = (attr) => attr.localName; +export const name = (attr) => attr.name; + export const getValue = (attr) => () => attr.value; export const setValue = (attr) => (value) => () => { diff --git a/src/Web/DOM/Attr.purs b/src/Web/DOM/Attr.purs index 6b6a34f..06c52b7 100644 --- a/src/Web/DOM/Attr.purs +++ b/src/Web/DOM/Attr.purs @@ -3,6 +3,7 @@ module Web.DOM.Attr , namespaceURI , prefix , localName + , name , getValue , setValue , ownerElement @@ -13,9 +14,10 @@ import Prelude import Data.Maybe (Maybe) import Data.Nullable (Nullable, toMaybe) import Effect (Effect) +import Web.DOM.AttrLocalName (AttrLocalName) import Web.DOM.AttrName (AttrName) -import Web.DOM.Internal.Types (Attr) as Exports import Web.DOM.Internal.Types (Attr, Element) +import Web.DOM.Internal.Types (Attr) as Exports import Web.DOM.NamespacePrefix (NamespacePrefix) import Web.DOM.NamespaceURI (NamespaceURI) @@ -29,7 +31,9 @@ foreign import _prefix :: Attr -> Nullable NamespacePrefix prefix :: Attr -> Maybe NamespacePrefix prefix attr = toMaybe (_prefix attr) -foreign import localName :: Attr -> AttrName +foreign import localName :: Attr -> AttrLocalName + +foreign import name :: Attr -> AttrName foreign import getValue :: Attr -> Effect String diff --git a/src/Web/DOM/AttrLocalName.purs b/src/Web/DOM/AttrLocalName.purs new file mode 100644 index 0000000..31b616f --- /dev/null +++ b/src/Web/DOM/AttrLocalName.purs @@ -0,0 +1,12 @@ +module Web.DOM.AttrLocalName where + +import Prelude + +import Data.Newtype (class Newtype) + +-- | A wrapper for attribute names. +newtype AttrLocalName = AttrLocalName String + +derive instance newtypeAttrLocalName :: Newtype AttrLocalName _ +derive newtype instance eqAttrLocalName :: Eq AttrLocalName +derive newtype instance ordAttrLocalName :: Ord AttrLocalName diff --git a/src/Web/DOM/DOMTokenList.js b/src/Web/DOM/DOMTokenList.js index 0c4e759..7a0e11c 100644 --- a/src/Web/DOM/DOMTokenList.js +++ b/src/Web/DOM/DOMTokenList.js @@ -82,12 +82,12 @@ export function setValue(list) { }; } -export function tokens(list) { +export function tokens(domTokenList) { return function () { - const result = []; - for (const token of list.tokens) { - result.push(token); + const tokens = []; + for (const token of domTokenList) { + tokens.push(token); } - return result; + return tokens; }; -} +} \ No newline at end of file