Skip to content
This repository has been archived by the owner on Feb 18, 2022. It is now read-only.

Commit

Permalink
Preserve spaces in multi-part values.
Browse files Browse the repository at this point in the history
This commit fixes the bug with space separated values. Previously, `0 10px 20px 30px` would be exported with commas: `0,10px,20px,30px`. This commit preverses spaces, to export `0 10px 20px 30px` as expected.
  • Loading branch information
Dave DeSandro authored and jonathantneal committed Jan 7, 2020
1 parent 1e1ef6b commit 44dfb33
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .tape.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = {
'--color': 'rgb(255, 0, 0)',
'--color-2': 'yellow',
'--ref-color': 'var(--color)',
'--margin': '0 10px 20px 30px',
'--z-index': 10
}
}
Expand All @@ -30,6 +31,7 @@ module.exports = {
'--color': 'rgb(255, 0, 0)',
'--color-2': 'yellow',
'--ref-color': 'var(--color)',
'--margin': '0 10px 20px 30px',
'--z-index': 10
}
};
Expand Down
5 changes: 4 additions & 1 deletion src/lib/write-custom-properties-to-exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ export default function writeCustomPropertiesToExports(customProperties, destina

const defaultCustomPropertiesToJSON = customProperties => {
return Object.keys(customProperties).reduce((customPropertiesJSON, key) => {
customPropertiesJSON[key] = String(customProperties[key]);
const valueNodes = customProperties[key];
customPropertiesJSON[key] = valueNodes.map((propertyObject) => {
return propertyObject.toString();
}).join(' ');

return customPropertiesJSON;
}, {});
Expand Down
1 change: 1 addition & 0 deletions test/basic.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ html {
--ref-color: var(--color);
--circular: var(--circular-2);
--circular-2: var(--circular);
--margin: 0 10px 20px 30px;
color: var(--color);
}

Expand Down
1 change: 1 addition & 0 deletions test/basic.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ html {
--ref-color: var(--color);
--circular: var(--circular-2);
--circular-2: var(--circular);
--margin: 0 10px 20px 30px;
color: rgb(255, 0, 0);
color: var(--color);
}
Expand Down
1 change: 1 addition & 0 deletions test/basic.import-is-empty.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ html {
--ref-color: var(--color);
--circular: var(--circular-2);
--circular-2: var(--circular);
--margin: 0 10px 20px 30px;
color: rgb(255, 0, 0);
color: var(--color);
}
Expand Down
1 change: 1 addition & 0 deletions test/basic.import.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ html {
--ref-color: var(--color);
--circular: var(--circular-2);
--circular-2: var(--circular);
--margin: 0 10px 20px 30px;
color: rgb(255, 0, 0);
color: var(--color);
}
Expand Down
1 change: 1 addition & 0 deletions test/export-properties.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
--color: rgb(255, 0, 0);
--circular: var(--circular-2);
--circular-2: var(--circular);
--margin: 0 10px 20px 30px;
}
3 changes: 2 additions & 1 deletion test/export-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = {
'--ref-color': 'var(--color)',
'--color': 'rgb(255, 0, 0)',
'--circular': 'var(--circular-2)',
'--circular-2': 'var(--circular)'
'--circular-2': 'var(--circular)',
'--margin': '0 10px 20px 30px'
}
};
3 changes: 2 additions & 1 deletion test/export-properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"--ref-color": "var(--color)",
"--color": "rgb(255, 0, 0)",
"--circular": "var(--circular-2)",
"--circular-2": "var(--circular)"
"--circular-2": "var(--circular)",
"--margin": "0 10px 20px 30px"
}
}
3 changes: 2 additions & 1 deletion test/export-properties.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export const customProperties = {
'--ref-color': 'var(--color)',
'--color': 'rgb(255, 0, 0)',
'--circular': 'var(--circular-2)',
'--circular-2': 'var(--circular)'
'--circular-2': 'var(--circular)',
'--margin': '0 10px 20px 30px'
};

0 comments on commit 44dfb33

Please sign in to comment.