Skip to content

Commit

Permalink
fix(okam-core): fix mixin source plain object reference
Browse files Browse the repository at this point in the history
  • Loading branch information
wuhy committed Nov 7, 2018
1 parent d1fa2ea commit c8d16e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/okam-core/src/base/application.js
Expand Up @@ -20,6 +20,8 @@ function initApis() {
if (!this.__apisInited) {
this.__apisInited = true;

Object.assign(this, base);

let promiseApis = this.$promisifyApis;
let interceptAPis = this.$interceptApis;

Expand All @@ -46,7 +48,7 @@ function initApis() {
return false;
}

export default Object.assign({
export default {

/**
* The hook when app launch
Expand All @@ -65,5 +67,5 @@ export default Object.assign({
onShow() {
initApis.call(this);
}
}, base);
};

5 changes: 3 additions & 2 deletions packages/okam-core/src/util/index.js
Expand Up @@ -60,7 +60,8 @@ function doMixin(target, source) {
target[k] = Object.assign({}, sValue, currValue);
}
else if (!target.hasOwnProperty(k)) {
target[k] = sValue;
target[k] = isPlainObject(sValue)
? Object.assign({}, sValue) : sValue;
}
}
}
Expand All @@ -71,7 +72,7 @@ function doMixin(target, source) {
* If the target has the prop, then the target will override the sources.
* If the target and sources prop value is both plain object will mixin.
* If the target and sources prop value is both function type, it'll create a new function,
* the function will call sources first (parent), then call target(child).
* the function will call sources first(parent), then call target(child).
*
* The mixin is shadow mixin, it means that only the first level props of the target will mixin.
* e.g., mixin({a: 3, b: {c: 5, d: {e: 2}}}, {a: 5, b: {d: {k: 5}, k: 5}, c: 10});
Expand Down

0 comments on commit c8d16e6

Please sign in to comment.