diff --git a/plugins/postcss-text-decoration-shorthand/dist/index.mjs b/plugins/postcss-text-decoration-shorthand/dist/index.mjs
index 46296ce26..f0c7605d6 100644
--- a/plugins/postcss-text-decoration-shorthand/dist/index.mjs
+++ b/plugins/postcss-text-decoration-shorthand/dist/index.mjs
@@ -1 +1 @@
-import e from"postcss-value-parser";import{namedColors as o}from"@csstools/color-helpers";const t=/^text-decoration$/i,creator=o=>{const c=Object.assign({preserve:!0},o);return{postcssPlugin:"postcss-text-decoration-shorthand",prepare(){const o=new Map;return{postcssPlugin:"postcss-text-decoration-shorthand",OnceExit(){o.clear()},Declaration(i){if(!t.test(i.prop))return;const a=i.parent;if(!a)return;const u=a.index(i);if(a.nodes.some(e=>"decl"===e.type&&t.test(e.prop)&&o.get(i.value)===e.value&&a.index(e)!==u))return;const d=e(i.value),p=d.nodes.filter(e=>"space"!==e.type&&"comment"!==e.type);if(p.find(e=>"var"===e.value.toLowerCase()&&"function"===e.type))return;if(p.find(e=>"word"===e.type&&r.includes(e.value)))return;const f={line:[],style:null,color:null,thickness:null};for(let o=0;o
{const c=Object.assign({preserve:!0},t);return{postcssPlugin:"postcss-text-decoration-shorthand",prepare(){const t=new Map;return{postcssPlugin:"postcss-text-decoration-shorthand",OnceExit(){t.clear()},Declaration(i){if(!o.test(i.prop))return;const a=i.parent;if(!a)return;const u=a.index(i);if(a.nodes.some(e=>"decl"===e.type&&o.test(e.prop)&&t.get(i.value)===e.value&&a.index(e)!==u))return;const d=e(i.value),p=d.nodes.filter(e=>"space"!==e.type&&"comment"!==e.type);if(p.find(e=>"var"===e.value.toLowerCase()&&"function"===e.type))return;if(p.find(e=>"word"===e.type&&r.includes(e.value)))return;const f={line:[],style:null,color:null,thickness:null};for(let t=0;t = (opts?: pluginOptions) => {
const options = Object.assign(
// Default options
@@ -192,8 +226,7 @@ const creator: PluginCreator = (opts?: pluginOptions) => {
const nonShortHandValue = valueParser.stringify(data.line);
if (decl.value.toLowerCase() === nonShortHandValue.toLowerCase()) {
- const next = decl.next();
- if (!next || next.type !== 'decl' || next.prop.toLowerCase() !== 'text-decoration') {
+ if (!hasFollowingTextDecoration(decl)) {
// "-webkit-text-decoration" is a shorthand and sets omitted constituent properties to their initial value.
// "text-decoration" is a longhand in older browsers and does not have this behavior.
@@ -206,10 +239,12 @@ const creator: PluginCreator = (opts?: pluginOptions) => {
return;
}
- decl.cloneBefore({
- prop: 'text-decoration',
- value: nonShortHandValue,
- });
+ if (!hasPreviousSameTextDecoration(decl, nonShortHandValue)) {
+ decl.cloneBefore({
+ prop: 'text-decoration',
+ value: nonShortHandValue,
+ });
+ }
const shortHandValue = valueParser.stringify([
...data.line,
diff --git a/plugins/postcss-text-decoration-shorthand/test/_tape.mjs b/plugins/postcss-text-decoration-shorthand/test/_tape.mjs
index d7eff4d87..4a6e87c9d 100644
--- a/plugins/postcss-text-decoration-shorthand/test/_tape.mjs
+++ b/plugins/postcss-text-decoration-shorthand/test/_tape.mjs
@@ -32,6 +32,15 @@ postcssTape(plugin)({
}),
],
},
+ 'multiple-declarations:autoprefixer': {
+ message: 'supports basic usage with autoprefixer',
+ plugins: [
+ plugin(),
+ autoprefixer({
+ overrideBrowserslist: ['Safari >= 8'],
+ }),
+ ],
+ },
'examples/example': {
message: 'minimal example',
},
diff --git a/plugins/postcss-text-decoration-shorthand/test/multiple-declarations.autoprefixer.expect.css b/plugins/postcss-text-decoration-shorthand/test/multiple-declarations.autoprefixer.expect.css
new file mode 100644
index 000000000..455554ab5
--- /dev/null
+++ b/plugins/postcss-text-decoration-shorthand/test/multiple-declarations.autoprefixer.expect.css
@@ -0,0 +1,5 @@
+.line-only-then-shorthand {
+ text-decoration: underline; /* 2 */
+ -webkit-text-decoration: underline dotted;
+ text-decoration: underline dotted;
+}
diff --git a/plugins/postcss-text-decoration-shorthand/test/multiple-declarations.css b/plugins/postcss-text-decoration-shorthand/test/multiple-declarations.css
new file mode 100644
index 000000000..0a330f931
--- /dev/null
+++ b/plugins/postcss-text-decoration-shorthand/test/multiple-declarations.css
@@ -0,0 +1,4 @@
+.line-only-then-shorthand {
+ text-decoration: underline; /* 2 */
+ text-decoration: underline dotted;
+}