Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Looky1173 committed Oct 8, 2022
1 parent 3881de1 commit 3ad60a8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/core/__tests__/compile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ describe('compile', () => {
});

it('value interpolations', () => {
// This interpolations are testing the ability to interpolate thruty and falsy values
// This interpolations are testing the ability to interpolate truthy and falsy values
expect(template`prop: 1; ${() => 0},${() => undefined},${() => null},${2}`({})).toEqual(
'prop: 1; 0,,,2'
'prop: 1; 0,_,_,2' // '_' represents a falsy value
);

const tmpl = template`
Expand All @@ -39,7 +39,7 @@ describe('compile', () => {
`;
expect(tmpl({})).toEqual(`
background: dodgerblue;
_
border: 1px solid blue;
`);
});
Expand Down
5 changes: 3 additions & 2 deletions src/core/__tests__/parse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,13 @@ describe('parse', () => {
{
div: {
opacity: 0,
color: null
color: null,
content: '""'
}
},
''
)
).toEqual('div{opacity:0;}');
).toEqual('div{opacity:0;content:"";}');
expect(
parse(
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export let compile = (str, defs, data) => {
// Here we check if this is strictly a boolean with false value
// define it as `''` to be picked up as empty, otherwise use
// res value
tail = res === false ? '' : res;
tail = res === false || res === undefined || res === null ? '_' : res;
}
}
return out + next + (tail == null ? '' : tail);
Expand Down
2 changes: 1 addition & 1 deletion src/core/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export let parse = (obj, selector) => {
})
: key
);
} else if (val != undefined) {
} else if (val != undefined && val !== '_') {
// Convert all but CSS variables
key = /^--/.test(key) ? key : key.replace(/[A-Z]/g, '-$&').toLowerCase();
// Push the line for this property
Expand Down

0 comments on commit 3ad60a8

Please sign in to comment.