Skip to content

Commit

Permalink
new version 1.0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
aOrz committed May 19, 2018
1 parent 8477239 commit ee07244
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 12 deletions.
2 changes: 1 addition & 1 deletion dist/vue.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -4629,7 +4629,7 @@ Object.defineProperty(Vue$3.prototype, '$ssrContext', {
});

Vue$3.version = '2.4.1';
Vue$3.mpvueVersion = '1.0.8';
Vue$3.mpvueVersion = '1.0.11';

/* */

Expand Down
2 changes: 1 addition & 1 deletion dist/vue.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -4627,7 +4627,7 @@ Object.defineProperty(Vue$3.prototype, '$ssrContext', {
});

Vue$3.version = '2.4.1';
Vue$3.mpvueVersion = '1.0.8';
Vue$3.mpvueVersion = '1.0.11';

/* */

Expand Down
2 changes: 1 addition & 1 deletion dist/vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -4618,7 +4618,7 @@ Object.defineProperty(Vue$3.prototype, '$ssrContext', {
});

Vue$3.version = '2.4.1';
Vue$3.mpvueVersion = '1.0.8';
Vue$3.mpvueVersion = '1.0.11';

/* */

Expand Down
2 changes: 1 addition & 1 deletion dist/vue.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/vue.runtime.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -4625,7 +4625,7 @@ Object.defineProperty(Vue$3.prototype, '$ssrContext', {
});

Vue$3.version = '2.4.1';
Vue$3.mpvueVersion = '1.0.8';
Vue$3.mpvueVersion = '1.0.11';

/* */

Expand Down
2 changes: 1 addition & 1 deletion dist/vue.runtime.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -4623,7 +4623,7 @@ Object.defineProperty(Vue$3.prototype, '$ssrContext', {
});

Vue$3.version = '2.4.1';
Vue$3.mpvueVersion = '1.0.8';
Vue$3.mpvueVersion = '1.0.11';

/* */

Expand Down
2 changes: 1 addition & 1 deletion dist/vue.runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -4614,7 +4614,7 @@ Object.defineProperty(Vue$3.prototype, '$ssrContext', {
});

Vue$3.version = '2.4.1';
Vue$3.mpvueVersion = '1.0.8';
Vue$3.mpvueVersion = '1.0.11';

/* */

Expand Down
2 changes: 1 addition & 1 deletion dist/vue.runtime.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/mpvue-template-compiler/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4580,7 +4580,7 @@ var component = {
var mpcomid = ast.mpcomid;
var slots = ast.slots;
if (slotName) {
attrsMap['data'] = "{{...$root[$p], $root}}";
attrsMap['data'] = "{{...$root[$k], $root}}";

This comment has been minimized.

Copy link
@shawtung

shawtung May 21, 2018

这样一改, 最基本的slot插值失效了.

attrsMap['is'] = "{{" + slotName + "}}";
} else {
var slotsName = getSlotsName(slots);
Expand Down
2 changes: 1 addition & 1 deletion packages/mpvue-template-compiler/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mpvue-template-compiler",
"version": "1.0.11",
"version": "1.0.12",
"description": "mpvue template compiler for Vue",
"main": "index.js",
"repository": {
Expand Down
49 changes: 48 additions & 1 deletion packages/mpvue/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4144,7 +4144,7 @@ Object.defineProperty(Vue$3.prototype, '$ssrContext', {
});

Vue$3.version = '2.4.1';
Vue$3.mpvueVersion = '1.0.9';
Vue$3.mpvueVersion = '1.0.11';

/* globals renderer */

Expand Down Expand Up @@ -4974,6 +4974,48 @@ function getGlobalData (app, rootVueVM) {
}
}

/**
* 格式化 properties 属性,并给每个属性加上 observer 方法
*/
function normalizeProperties (vm) {
var properties = vm.$options.properties || {};
var res = {};
var val;
var loop = function ( key ) {
val = isPlainObject(properties[key])
? properties[key]
: { type: properties[key] };
res[key] = {
type: val.type,
value: val.value,
observer: function observer (newVal, oldVal) {
vm[key] = newVal; // 先修改值再触发原始的 observer,跟 watch 行为保持一致
if (typeof val.observer === 'function') {
val.observer.call(vm, newVal, oldVal);
}
}
};
};

for (var key in properties) loop( key );
return res
}

/**
* 把 properties 中的属性 proxy 到 vm 上
*/
function initMpProps (vm) {
var mpProps = vm._mpProps = {};
var keys = Object.keys(vm.$options.properties || {});
keys.forEach(function (key) {
if (!(key in vm)) {
proxy(vm, '_mpProps', key);
mpProps[key] = undefined; // for observe
}
});
observe(mpProps, true);
}

function initMP (mpType, next) {
var rootVueVM = this.$root;
if (!rootVueVM.$mp) {
Expand Down Expand Up @@ -5041,7 +5083,11 @@ function initMP (mpType, next) {
}
});
} else if (mpType === 'component') {
initMpProps(rootVueVM);

global.Component({
// 小程序原生的组件属性
properties: normalizeProperties(rootVueVM),
// 页面的初始数据
data: {
$root: {}
Expand Down Expand Up @@ -5192,6 +5238,7 @@ function getVmData (vm) {
var dataKeys = [].concat(
Object.keys(vm._data || {}),
Object.keys(vm._props || {}),
Object.keys(vm._mpProps || {}),
Object.keys(vm._computedWatchers || {})
);
return dataKeys.reduce(function (res, key) {
Expand Down
2 changes: 1 addition & 1 deletion packages/mpvue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mpvue",
"version": "1.0.11",
"version": "1.0.12",
"description": "Vue Runtime for mini program",
"main": "index.js",
"repository": {
Expand Down

0 comments on commit ee07244

Please sign in to comment.