diffing chunks of dom or HTML for semantic equality
npm install @swimlane/dom-diffThis library acts as a base project for diffing chunks of dom or HTML for semantic equality.
Used in:
- @swimlane/cy-dom-diff
Takes a snippet of HTML and returns a semantically similar diffable HTML snippet.
``js
import { getDiffableHTML } from '@swimlane/dom-diff';
const h =
;getDiffableHTML(h, {
ignoreAttributes: [{ tags: ['h1'], attributes: ['z'] }]
});
//
// a="2"
// x
// z="1"
// >
//
// Hello
//
//
// World
//
// $3
Template tag that takes a snippet of HTML and returns a regular expression.
> Follows rules defined in https://github.com/Hypercubed/lit-regex
`js
import { dom } from '@swimlane/dom-diff';dom
;// /^
\n Hello [\w-]+\n<\/h1>$/
`$3
Takes a regular expression generated by
dom and a string generated from getDiffableHTML returning a representation of the difference.`js
import { diff, dom, getDiffableHTML } from '@swimlane/dom-diff';const h = getDiffableHTML('
Hello 123');
const r = dom;diff(r, h);
//
// - Hello \${/[a-zA-Z]+/}
// + Hello 123
//
`
Release
- Checkout main (
git checkout main)
- Pull from origin (git pull origin main)
- Examine CHANGELOG.md to determine next version (X.Y.Z)
- Run np (npm run np) and follow the promptsLicense
Distributed under the MIT License. See LICENSE for more information.
Credits
@swimlane/dom-diff` is a Swimlane open-source project; weSwimlane is an automated cyber security operations and incident response
platform that enables cyber security teams to leverage threat intelligence,
speed up incident response and automate security operations.