Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,11 @@ function filterAuthorInlineStyles(context, element) {
: null;
const defaultStyle = getDefaultStyle(context, element);

// Remove property declarations that are duplicated from a parent element.
if (parentComputedStyle) {
removeDuplicateCustomProperties(styles, parentComputedStyle);
}

// Splice explicit inline style declarations that match default and parent values.
tokenizeCssTextDeclarations(styles.inline.cssText)
.map(getCssTextProperty)
Expand Down Expand Up @@ -1022,6 +1027,21 @@ function destroyElementHierarchy(element) {
}
}

/**
* Removes duplicate CSS properties from the parent element's style.
*
* @param {Styles} styles Styles object for the element.
* @param {CSSStyleDeclaration} parentStyle Parent element's style declaration.
*/
function removeDuplicateCustomProperties(styles, parentStyle) {
for (const name of parentStyle) {
const parentValue = parentStyle.getPropertyValue(name);
if (name.startsWith('--') && styles.inline.getPropertyValue(name) === parentValue) {
styles.inline.removeProperty(name);
}
}
}

/**
* Tokenize inline CSS styling declarations.
*
Expand Down