Skip to content

Commit

Permalink
Merge pull request #44 from streamich/fix/debug
Browse files Browse the repository at this point in the history
Fix/debug
  • Loading branch information
streamich authored Feb 13, 2018
2 parents daaf835 + 2a8d5aa commit f67969c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 16 deletions.
9 changes: 9 additions & 0 deletions .storybook/css/StoryStatic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,12 @@ export class Button extends Component<any, any> {
return <button>Hello world!</button>;
}
}

/*@css
export class Button extends Compnent<any, any> {
static css
render () {
}
}
*/
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "freestyler",
"version": "1.6.0",
"version": "1.6.4",
"description": "5th generation React styling library",
"main": "lib/index.js",
"module": "modules/index.js",
Expand Down
22 changes: 15 additions & 7 deletions src/debug/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import createBroadcaster from './createBroadcaster';
import {sym} from '../util';

const broadcaster = createBroadcaster();
const $$debug = sym('debug');
const channel = process.env.FREESTYLER_PREFIX || 'default';
let broadcaster: any = {
emit: () => {},
};

if (!window[$$debug]) {
window[$$debug] = {};
}
const isClient = typeof window === 'object';

if (isClient) {
broadcaster = createBroadcaster();
const $$debug = sym('debug');
const channel = process.env.FREESTYLER_PREFIX || 'default';

window[$$debug][channel] = broadcaster;
if (!window[$$debug]) {
window[$$debug] = {};
}

window[$$debug][channel] = broadcaster;
}

export const emit = action => broadcaster.emit(action);
20 changes: 12 additions & 8 deletions src/renderer/Renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,14 @@ class Renderer implements IRenderer {
}

unrender(Comp, instance, el: HTMLElement | null) {
require('../debug').emit({
type: 'UNRENDER',
Comp,
instance,
el,
});
if (process.env.NODE_ENV !== 'production') {
require('../debug').emit({
type: 'UNRENDER',
Comp,
instance,
el,
});
}

// Remove statics
const cacheMap = instance[$$statics] as {[key: string]: DeclarationCache};
Expand All @@ -412,8 +414,8 @@ class Renderer implements IRenderer {
if (dynamics) {
dynamics.destroy();
// TODO: Do we really need this line?
instance[$$dynamics] = null;
// delete instance[$$dynamics];
// instance[$$dynamics] = null;
delete instance[$$dynamics];
}
}

Expand All @@ -422,6 +424,8 @@ class Renderer implements IRenderer {

if (classNames === void 0) {
hidden(Comp, $$cn, '');
} else {
return classNames;
}

let styles = tplToStyles(tpl, args);
Expand Down

0 comments on commit f67969c

Please sign in to comment.