Skip to content

Commit

Permalink
shaved another 1 byte for cjs and umd
Browse files Browse the repository at this point in the history
  • Loading branch information
RealPeha committed Jan 15, 2022
1 parent 92fdb00 commit b8c8503
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 25 deletions.
3 changes: 3 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { extractCss } from './core/update';
export { styled, setup } from './styled';
export { css, glob, keyframes } from './css';
36 changes: 18 additions & 18 deletions src/__tests__/integrations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,17 @@ describe('integrations', () => {
'"',
' ', // Empty white space that holds the textNode that the styles are appended
'@keyframes go384228713{0%{opacity:0;}99%{opacity:1;color:dodgerblue;}}',
'.go2626112847{opacity:0;background:cyan;}',
'.go3244392539{opacity:0;background:cyan;}',
'.go3865451590{color:red;}',
'.go3991234422{color:cyan;}',
'.go3991234422 .go3865451590{border:1px solid red;}',
'.go1925576363{color:blue;}',
'.go3206651468{color:green;}',
'.go4276997079{color:orange;}',
'.go2069586824{opacity:0;animation:go384228713 500ms ease-in-out;}',
'.go2648019963{foo:1;color:red;baz:0;}',
'.go3913223576{opacity:0;}',
'.go3863620777{opacity:0;baz:0;}',
'.go1162043959{foo:1;color:red;baz:0;}',
'.go98589992{opacity:0;}',
'.go3678641885{opacity:0;baz:0;}',
'"'
].join('')
);
Expand Down Expand Up @@ -162,21 +162,21 @@ describe('integrations', () => {
expect(target.innerHTML).toEqual(
[
'<div>',
'<div class="go748886164"></div>',
'<div class="go748906566"></div>',
'<span class="go2235611440"></span>',
'<button class="go468399569 go1824201605"></button>',
'<div class="go2623058580"></div>',
'<div class="go2625119182"></div>',
'<span class="go2458456096"></span>',
'<button class="go63716261 go1824201605"></button>',
'</div>'
].join('')
);

expect(extractCss()).toMatchInlineSnapshot(
[
'"',
'.go468399569{color:white;padding:0em;margin:1em;}',
'.go748886164{color:white;padding:0em;}',
'.go748906566{color:white;padding:2em;}',
'.go2235611440{color:white;padding:3em;margin:1em;}',
'.go63716261{color:white;padding:0em;margin:1em;}',
'.go2623058580{color:white;padding:0em;}',
'.go2625119182{color:white;padding:2em;}',
'.go2458456096{color:white;padding:3em;margin:1em;}',
'.go1824201605{background:dodgerblue;}',
'"'
].join('')
Expand Down Expand Up @@ -216,9 +216,9 @@ describe('integrations', () => {
expect(target.innerHTML).toEqual(
[
'<div>',
'<div class="go748886164"></div>',
'<div class="go748906566"></div>',
'<span class="go2235611440"></span>',
'<div class="go2623058580"></div>',
'<div class="go2625119182"></div>',
'<span class="go2458456096"></span>',
'</div>'
].join(''),
`"<div><div class=\\"go103173764\\"></div><div class=\\"go103194166\\"></div><span class=\\"go2081835032\\"></span></div>"`
Expand All @@ -227,9 +227,9 @@ describe('integrations', () => {
expect(extractCss()).toMatchInlineSnapshot(
[
'"',
'.go748886164{color:white;padding:0em;}',
'.go748906566{color:white;padding:2em;}',
'.go2235611440{color:white;padding:3em;margin:1em;}',
'.go2623058580{color:white;padding:0em;}',
'.go2625119182{color:white;padding:2em;}',
'.go2458456096{color:white;padding:3em;margin:1em;}',
'"'
].join('')
);
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/styled.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('styled', () => {
className: 'go',
color: 'red'
});
expect(extractCss()).toEqual('.go3127686001{color:red;}');
expect(extractCss()).toEqual('.go2363673541{color:red;}');
});

it('change tag via "as" prop', () => {
Expand Down Expand Up @@ -154,6 +154,6 @@ describe('styled', () => {
let vnode = Tag({ draw: true });

expect(vnode).toMatchVNode('tag', { className: 'go', draw: true });
expect(extractCss()).toEqual('.go452517270{color:yellow;}');
expect(extractCss()).toEqual('.go2754571358{color:yellow;}');
});
});
6 changes: 3 additions & 3 deletions src/core/__tests__/hash.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('hash', () => {

const res = hash({ baz: 1 }, 'target');

expect(toHash).toBeCalledWith('baz,1');
expect(toHash).toBeCalledWith('baz,10');
expect(astish).not.toBeCalled();
expect(parse).toBeCalledWith({ baz: 1 }, '.' + className);
expect(update).toBeCalledWith('parse()', 'target', undefined);
Expand All @@ -100,12 +100,12 @@ describe('hash', () => {

// Since it's not yet cached
hash({ cacheObject: 1 }, 'target');
expect(toHash).toBeCalledWith('cacheObject,1');
expect(toHash).toBeCalledWith('cacheObject,10');
toHash.mockClear();

// Different object
hash({ foo: 2 }, 'target');
expect(toHash).toBeCalledWith('foo,2');
expect(toHash).toBeCalledWith('foo,20');
toHash.mockClear();

// First object should not call .toHash
Expand Down
3 changes: 1 addition & 2 deletions src/core/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ let cache = {};
*/
export let hash = (compiled, sheet, global, append, keyframes) => {
// Get a string representation of the object or the value that is called 'compiled'
let stringifiedCompiled =
typeof compiled == 'object' ? Object.entries(compiled) + '' : compiled;
let stringifiedCompiled = typeof compiled == 'object' ? Object.entries(compiled) + 0 : compiled;

// Retrieve the className from cache or hash it in place
let className =
Expand Down

0 comments on commit b8c8503

Please sign in to comment.