Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 1ca0812

Browse files
committed
1.0.3 release - bugfix
1 parent aff0df5 commit 1ca0812

File tree

6 files changed

+105
-150
lines changed

6 files changed

+105
-150
lines changed

modules/component-async.js

-23
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ const actions = (viewObject) => {
8787
const getState = () => viewObject.actions.state;
8888

8989
const setState = async (newState = {}, callback = null, updateView = true) => {
90-
console.log('Setting new state...');
91-
9290
let state = newState;
9391
let shouldComponentUpdate = true;
9492

@@ -98,7 +96,6 @@ const actions = (viewObject) => {
9896

9997
viewObject.actions.state = defaultsDeepPreserveArrays(state, viewObject.actions.state);
10098

101-
console.log('shouldComponentUpdate');
10299
if (isFunction(viewObject.actions.shouldComponentUpdate)) {
103100
shouldComponentUpdate = await !!viewObject.actions.shouldComponentUpdate(viewObject.actions.state, viewObject.actions);
104101
} else {
@@ -107,14 +104,12 @@ const actions = (viewObject) => {
107104

108105
if (shouldComponentUpdate) {
109106
if (updateView) {
110-
console.log('componentWillUpdate');
111107
if (viewObject.actions.componentWillUpdate && isFunction(viewObject.actions.componentWillUpdate)) {
112108
await viewObject.actions.componentWillUpdate(viewObject.actions.state, viewObject.actions, viewObject);
113109
}
114110

115111
viewObject.nodes.view = patch(viewObject.nodes.view, viewObject.component.getViewComponent(viewObject.actions.state));
116112

117-
console.log('componentDidUpdate');
118113
if (viewObject.actions.componentDidUpdate && isFunction(viewObject.actions.componentDidUpdate)) {
119114
await viewObject.actions.componentDidUpdate(viewObject.actions.state, viewObject.actions);
120115
}
@@ -149,8 +144,6 @@ const actions = (viewObject) => {
149144

150145
return result;
151146
});
152-
} else {
153-
console.error('Please provide reducer function to use this functionality!');
154147
}
155148
};
156149

@@ -195,8 +188,6 @@ const actions = (viewObject) => {
195188

196189
const componentFn = (viewObject) => {
197190
const getViewComponent = (newState) => {
198-
console.log('Getting view...');
199-
200191
if (viewObject.actions.render && isFunction(viewObject.actions.render)) {
201192
let node = null;
202193

@@ -213,14 +204,10 @@ const componentFn = (viewObject) => {
213204
};
214205

215206
const getViewContext = () => {
216-
console.log('Finding view context...');
217-
218207
if (viewObject.actions.spinner) {
219-
console.log('View context found: Spinner');
220208
return loader(viewObject.actions);
221209
}
222210

223-
console.log('View context found: `render()` result');
224211
return getViewComponent(viewObject.actions.state);
225212
};
226213

@@ -338,7 +325,6 @@ const createAsyncComponent = async (params = defaultParams) => {
338325
}
339326

340327
if (params.componentWillCreateViewObject && isFunction(params.componentWillCreateViewObject)) {
341-
console.log('componentWillCreateViewObject');
342328
params.componentWillCreateViewObject(params.state);
343329
}
344330

@@ -356,7 +342,6 @@ const createAsyncComponent = async (params = defaultParams) => {
356342
viewObject.component = componentFn(viewObject);
357343

358344
if (viewObject.actions.componentWillInit && isFunction(viewObject.actions.componentWillInit)) {
359-
console.log('componentWillInit');
360345
viewObject.actions.componentWillInit(viewObject.actions.state, viewObject.actions);
361346
}
362347

@@ -369,43 +354,36 @@ const createAsyncComponent = async (params = defaultParams) => {
369354
...viewObject.nodes.view.data,
370355
hook: {
371356
init: () => {
372-
console.log('init');
373357
if (viewObject.actions.componentDidInit && isFunction(viewObject.actions.componentDidInit)) {
374358
viewObject.actions.componentDidInit(viewObject.actions.state, viewObject.actions);
375359
}
376360
},
377361
create: () => {
378-
console.log('componentWillMount');
379362
if (viewObject.actions.componentWillMount && isFunction(viewObject.actions.componentWillMount)) {
380363
viewObject.actions.componentWillMount(viewObject.actions.state, viewObject.actions);
381364
}
382365
},
383366
prepatch: () => {
384-
console.log('prepatch');
385367
if (viewObject.actions.componentWillPrepatch && isFunction(viewObject.actions.componentWillPrepatch)) {
386368
viewObject.actions.componentWillPrepatch(viewObject.actions.state, viewObject.actions);
387369
}
388370
},
389371
postpatch: () => {
390-
console.log('postpatch');
391372
if (viewObject.actions.componentWillPostpatch && isFunction(viewObject.actions.componentWillPostpatch)) {
392373
viewObject.actions.componentWillPostpatch(viewObject.actions.state, viewObject.actions);
393374
}
394375
},
395376
insert: () => {
396-
console.log('componentDidMount');
397377
if (viewObject.actions.componentDidMount && isFunction(viewObject.actions.componentDidMount)) {
398378
viewObject.actions.componentDidMount(viewObject.actions.state, viewObject.actions);
399379
}
400380
},
401381
destroy: () => {
402-
console.log('componentWillUnmount');
403382
if (viewObject.actions.componentWillUnmount && isFunction(viewObject.actions.componentWillUnmount)) {
404383
viewObject.actions.componentWillUnmount(viewObject.actions.state, viewObject.actions);
405384
}
406385
},
407386
remove: (vnode, removeCallback) => {
408-
console.log('componentDidUnmount');
409387
if (viewObject.actions.componentDidUnmount && isFunction(viewObject.actions.componentDidUnmount)) {
410388
viewObject.actions.componentDidUnmount(viewObject.actions.state, viewObject.actions);
411389
}
@@ -416,7 +394,6 @@ const createAsyncComponent = async (params = defaultParams) => {
416394
};
417395

418396
if (viewObject.actions.componentDidCreateViewObject && isFunction(viewObject.actions.componentDidCreateViewObject)) {
419-
console.log('componentDidCreateViewObject');
420397
viewObject.actions.componentDidCreateViewObject(viewObject.actions.state, viewObject.actions);
421398
}
422399

modules/component.js

+1-25
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ const actions = (viewObject) => {
5252
const getState = () => viewObject.actions.state;
5353

5454
const setState = (newState = {}, callback = null, updateView = true) => {
55-
console.log('Setting new state...');
56-
5755
let state = newState;
5856
let shouldComponentUpdate = true;
5957

@@ -63,7 +61,6 @@ const actions = (viewObject) => {
6361

6462
viewObject.actions.state = defaultsDeepPreserveArrays(state, viewObject.actions.state);
6563

66-
console.log('shouldComponentUpdate');
6764
if (isFunction(viewObject.actions.shouldComponentUpdate)) {
6865
shouldComponentUpdate = !!viewObject.actions.shouldComponentUpdate(viewObject.actions.state, viewObject.actions);
6966
} else {
@@ -72,7 +69,6 @@ const actions = (viewObject) => {
7269

7370
if (shouldComponentUpdate) {
7471
if (updateView) {
75-
console.log('componentWillUpdate');
7672
if (viewObject.actions.componentWillUpdate) {
7773
if (isFunction(viewObject.actions.componentWillUpdate)) {
7874
viewObject.actions.componentWillUpdate(viewObject.actions.state, viewObject.actions, viewObject);
@@ -81,7 +77,6 @@ const actions = (viewObject) => {
8177

8278
viewObject.nodes.view = patch(viewObject.nodes.view, viewObject.component.getViewComponent(viewObject.actions.state));
8379

84-
console.log('componentDidUpdate');
8580
if (viewObject.actions.componentDidUpdate) {
8681
if (isFunction(viewObject.actions.componentDidUpdate)) {
8782
viewObject.actions.componentDidUpdate(viewObject.actions.state, viewObject.actions);
@@ -116,8 +111,6 @@ const actions = (viewObject) => {
116111

117112
return viewObject.actions.reducer(prevState, nextAction, viewObject.actions);
118113
});
119-
} else {
120-
console.error('Please provide reducer function to use this functionality!');
121114
}
122115
};
123116

@@ -159,8 +152,6 @@ const actions = (viewObject) => {
159152

160153
const componentFn = (viewObject) => {
161154
const getViewComponent = (newState) => {
162-
console.log('Getting view...');
163-
164155
if (viewObject.actions.render && isFunction(viewObject.actions.render)) {
165156
let node = null;
166157

@@ -176,12 +167,7 @@ const componentFn = (viewObject) => {
176167
return h('div', 'Nothing to render');
177168
};
178169

179-
const getViewContext = () => {
180-
console.log('Finding view context...');
181-
182-
console.log('View context found: `render()` result');
183-
return getViewComponent(viewObject.actions.state);
184-
};
170+
const getViewContext = () => getViewComponent(viewObject.actions.state);
185171

186172
const profileHook = (hook) => {
187173
const types = uniq(map(hook, (hk) => {
@@ -295,7 +281,6 @@ const createComponent = (params = defaultParams) => {
295281
params.state = isFunction(params.state) ? params.state(params) : params.state;
296282

297283
if (params.componentWillCreateViewObject && isFunction(params.componentWillCreateViewObject)) {
298-
console.log('componentWillCreateViewObject');
299284
params.componentWillCreateViewObject(params.state);
300285
}
301286

@@ -313,7 +298,6 @@ const createComponent = (params = defaultParams) => {
313298
viewObject.component = componentFn(viewObject);
314299

315300
if (viewObject.actions.componentWillInit && isFunction(viewObject.actions.componentWillInit)) {
316-
console.log('componentWillInit');
317301
viewObject.actions.componentWillInit(viewObject.actions.state, viewObject.actions);
318302
}
319303

@@ -326,43 +310,36 @@ const createComponent = (params = defaultParams) => {
326310
...viewObject.nodes.view.data,
327311
hook: {
328312
init: () => {
329-
console.log('init');
330313
if (viewObject.actions.componentDidInit && isFunction(viewObject.actions.componentDidInit)) {
331314
viewObject.actions.componentDidInit(viewObject.actions.state, viewObject.actions);
332315
}
333316
},
334317
create: () => {
335-
console.log('componentWillMount');
336318
if (viewObject.actions.componentWillMount && isFunction(viewObject.actions.componentWillMount)) {
337319
viewObject.actions.componentWillMount(viewObject.actions.state, viewObject.actions);
338320
}
339321
},
340322
prepatch: () => {
341-
console.log('prepatch');
342323
if (viewObject.actions.componentWillPrepatch && isFunction(viewObject.actions.componentWillPrepatch)) {
343324
viewObject.actions.componentWillPrepatch(viewObject.actions.state, viewObject.actions);
344325
}
345326
},
346327
postpatch: () => {
347-
console.log('postpatch');
348328
if (viewObject.actions.componentWillPostpatch && isFunction(viewObject.actions.componentWillPostpatch)) {
349329
viewObject.actions.componentWillPostpatch(viewObject.actions.state, viewObject.actions);
350330
}
351331
},
352332
insert: () => {
353-
console.log('componentDidMount');
354333
if (viewObject.actions.componentDidMount && isFunction(viewObject.actions.componentDidMount)) {
355334
viewObject.actions.componentDidMount(viewObject.actions.state, viewObject.actions);
356335
}
357336
},
358337
destroy: () => {
359-
console.log('componentWillUnmount');
360338
if (viewObject.actions.componentWillUnmount && isFunction(viewObject.actions.componentWillUnmount)) {
361339
viewObject.actions.componentWillUnmount(viewObject.actions.state, viewObject.actions);
362340
}
363341
},
364342
remove: (vnode, removeCallback) => {
365-
console.log('componentDidUnmount');
366343
if (viewObject.actions.componentDidUnmount && isFunction(viewObject.actions.componentDidUnmount)) {
367344
viewObject.actions.componentDidUnmount(viewObject.actions.state, viewObject.actions);
368345
}
@@ -373,7 +350,6 @@ const createComponent = (params = defaultParams) => {
373350
};
374351

375352
if (viewObject.actions.componentDidCreateViewObject && isFunction(viewObject.actions.componentDidCreateViewObject)) {
376-
console.log('componentDidCreateViewObject');
377353
viewObject.actions.componentDidCreateViewObject(viewObject.actions.state, viewObject.actions);
378354
}
379355

modules/styled.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ####### Declarations ##########
22
const h = require('../vendors/snabbdom/h.js');
33
const cssToJS = require('../utils/cssToJS.js');
4-
const { forEach, has, filter } = require('lodash');
4+
const { forEach, has, filter, defaultsDeep } = require('lodash');
55
const { mergeWithFn, ss } = require('../utils/helpers.js');
66
const { isDefinedChild } = require('../utils/vDomHelpers.js');
77

@@ -19,21 +19,23 @@ const defaultData = {
1919
};
2020

2121
// ####### Helpers ##########
22-
const getVNode = (sel = 'div', literals, ...expressions) => (d = { ...defaultData }, c) => {
22+
const getVNode = (sel = 'div', literals, ...expressions) => (d = defaultData, c) => {
2323
let data = d;
2424
let children = c;
2525

2626
if (!children && isDefinedChild(data)) {
2727
children = data;
2828
data = { ...defaultData };
2929
} else {
30-
data = { ...defaultData, ...data };
30+
data = defaultsDeep(data, defaultData);
3131
}
3232

3333
const props = data.styled;
3434

35-
const style = cssWithProps(props, data)(literals, ...expressions);
36-
const defprops = { style, styledProps: { css: cssWithPropsPlain(props, data)(literals, ...expressions) } };
35+
const css = cssWithPropsPlain(props, data)(literals, ...expressions);
36+
const style = cssToJS(css);
37+
38+
const defprops = { style, styledProps: { css } };
3739

3840
return h(sel, mergeWithFn(defprops, data), filter(children, child => isDefinedChild(child)));
3941
};

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "snabbdom-react-components",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "React like, Snabbdom based, Virtual Dom framework for JavaScript Web Applications",
55
"keywords": [
66
"React",

0 commit comments

Comments
 (0)