diff --git a/CHANGELOG.md b/CHANGELOG.md index 885be61..8093bbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Breaking changes: - The `getAttribute`, `setAttribute`, `hasAttribute`, and `removeAttribute` functions are parameterized by `AttrName` instead of `String`. (#58 by @nsaunders) New features: +- Added `isSameNode` function. (#44 by @wclr) - `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) - `scrollIntoView` and `scrollIntoViewWithOptions` (with typed `ScrollBehavior` and `ScrollLogicalPosition`) have been added. (#64 by @i-am-the-slime) diff --git a/src/Web/DOM/Node.js b/src/Web/DOM/Node.js index 166b358..66249d2 100644 --- a/src/Web/DOM/Node.js +++ b/src/Web/DOM/Node.js @@ -76,6 +76,12 @@ export function isEqualNode(node1) { }; } +export function isSameNode(node1) { + return function (node2) { + return node1.isSameNode(node2); + }; +} + export function compareDocumentPositionBits(node1) { return function (node2) { return function () { diff --git a/src/Web/DOM/Node.purs b/src/Web/DOM/Node.purs index 034dca6..fa27011 100644 --- a/src/Web/DOM/Node.purs +++ b/src/Web/DOM/Node.purs @@ -23,6 +23,7 @@ module Web.DOM.Node , clone , deepClone , isEqualNode + , isSameNode , compareDocumentPositionBits , contains , lookupPrefix @@ -157,6 +158,9 @@ foreign import deepClone :: Node -> Effect Node -- | Checks whether two nodes are equivalent. foreign import isEqualNode :: Node -> Node -> Effect Boolean +-- | Checks whether two nodes are the same. +foreign import isSameNode :: Node -> Node -> Boolean + -- TODO: compareDocumentPosition that returns a semigroup or something instead of the bitmask value -- | Compares the position of two nodes in the document.