Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@open-wc/semantic-dom-diff

Package Overview
Dependencies
Maintainers
2
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@open-wc/semantic-dom-diff - npm Package Compare versions

Comparing version 0.14.1 to 0.14.2

12

CHANGELOG.md

@@ -6,2 +6,14 @@ # Change Log

## [0.14.2](https://github.com/open-wc/open-wc/compare/@open-wc/semantic-dom-diff@0.14.1...@open-wc/semantic-dom-diff@0.14.2) (2019-09-15)
### Bug Fixes
* do not destructure exports to support es-module-lexer ([3709413](https://github.com/open-wc/open-wc/commit/3709413))
* **semantic-dom-diff:** strip empty class attrs when diffing ([#799](https://github.com/open-wc/open-wc/issues/799)) ([f2eea9d](https://github.com/open-wc/open-wc/commit/f2eea9d))
## [0.14.1](https://github.com/open-wc/open-wc/compare/@open-wc/semantic-dom-diff@0.14.0...@open-wc/semantic-dom-diff@0.14.1) (2019-08-18)

@@ -8,0 +20,0 @@

54

get-diffable-html.js

@@ -23,2 +23,9 @@ const DEFAULT_IGNORE_TAGS = ['script', 'style', 'svg'];

/**
* Reverses the sense of a predicate
* @param {(x: any) => Boolean} p predicate
* @return {(x: any) => Boolean}
*/
const not = p => (...args) => !p(...args);
/**
* @typedef IgnoreAttributesForTags

@@ -115,2 +122,6 @@ * @property {string[]} tags tags on which to ignore the given attributes

function shouldStripAttribute({ name, value }) {
return stripEmptyAttributes.includes(name) && value === '';
}
/**

@@ -121,12 +132,5 @@ * @param {Element} el

function getAttributeString(el, { name, value }) {
const shouldStripAttr = stripEmptyAttributes.includes(name) && value === '';
const isClassAttr = name === 'class';
return (
// eslint-disable-next-line no-nested-ternary
shouldStripAttr
? ''
: isClassAttr
? ` class="${getClassListValueString(el)}"`
: ` ${name}="${value}"`
);
if (shouldStripAttribute({ name, value })) return '';
if (name === 'class') return ` class="${getClassListValueString(el)}"`;
return ` ${name}="${value}"`;
}

@@ -136,17 +140,19 @@

* @param {Element} el
* @param {Attr} attr
* @return {(attr: Attr) => Boolean}
*/
function isIgnoredAttribute(el, attr) {
if (ignoreAttributes.includes(attr.name)) {
return true;
}
function isIgnoredAttribute(el) {
return function isIgnoredElementAttibute(attr) {
if (ignoreAttributes.includes(attr.name) || shouldStripAttribute(attr)) {
return true;
}
return !!ignoreAttributesForTags.find(e => {
if (!e.tags || !e.attributes) {
throw new Error(
`An object entry to ignoreAttributes should contain a 'tags' and an 'attributes' property.`,
);
}
return e.tags.includes(el.nodeName.toLowerCase()) && e.attributes.includes(attr.name);
});
return !!ignoreAttributesForTags.find(e => {
if (!e.tags || !e.attributes) {
throw new Error(
`An object entry to ignoreAttributes should contain a 'tags' and an 'attributes' property.`,
);
}
return e.tags.includes(el.nodeName.toLowerCase()) && e.attributes.includes(attr.name);
});
};
}

@@ -160,3 +166,3 @@

const attributes = Array.from(el.attributes)
.filter(attr => !isIgnoredAttribute(el, attr))
.filter(not(isIgnoredAttribute(el)))
.sort(sortAttribute);

@@ -163,0 +169,0 @@

{
"name": "@open-wc/semantic-dom-diff",
"version": "0.14.1",
"version": "0.14.2",
"description": "To compare dom and shadow dom trees. Part of open-wc recommendations",

@@ -30,3 +30,3 @@ "author": "open-wc",

},
"gitHead": "367563168e6aeda65c1c8f11a31b937db02ab6e1"
"gitHead": "b57f10dd010c35e1fa1a40365f90e5a7adf194f5"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc