Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
m0_68066342
uni-app
提交
784d0e2b
U
uni-app
项目概览
m0_68066342
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
784d0e2b
编写于
10月 25, 2019
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(v3): diff
上级
eb2f83a1
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
234 addition
and
140 deletion
+234
-140
packages/uni-app-plus/dist/index.v3.js
packages/uni-app-plus/dist/index.v3.js
+52
-7
packages/uni-app-plus/dist/view.umd.js
packages/uni-app-plus/dist/view.umd.js
+123
-124
src/platforms/app-plus/service/framework/plugins/diff.js
src/platforms/app-plus/service/framework/plugins/diff.js
+47
-4
src/platforms/app-plus/service/framework/plugins/vdom-sync.js
...platforms/app-plus/service/framework/plugins/vdom-sync.js
+10
-3
src/platforms/app-plus/view/framework/plugins/event.js
src/platforms/app-plus/view/framework/plugins/event.js
+2
-2
未找到文件。
packages/uni-app-plus/dist/index.v3.js
浏览文件 @
784d0e2b
...
...
@@ -9119,17 +9119,24 @@ var serviceContext = (function () {
};
}
function
wrapperEvent
(
event
)
{
event
.
preventDefault
=
noop
;
event
.
stopPropagation
=
noop
;
event
.
mp
=
event
;
return
Object
.
assign
({
mp
:
event
// mpvue
},
event
)
}
const
handleVdData
=
{
[
UI_EVENT
]:
function
onUIEvent
(
vdBatchEvent
,
vd
)
{
vdBatchEvent
.
forEach
(([
cid
,
nid
,
event
])
=>
{
nid
=
String
(
nid
);
event
.
preventDefault
=
noop
;
event
.
stopPropagation
=
noop
;
const
target
=
vd
.
elements
.
find
(
target
=>
target
.
cid
===
cid
&&
target
.
nid
===
nid
);
if
(
!
target
)
{
return
console
.
error
(
`event handler[
${
cid
}
][
${
nid
}
] not found`
)
}
target
.
dispatchEvent
(
event
.
type
,
event
);
target
.
dispatchEvent
(
event
.
type
,
wrapperEvent
(
event
)
);
});
}
};
...
...
@@ -9234,15 +9241,53 @@ var serviceContext = (function () {
data
[
k
]
=
v
;
}
function
diffObject
(
newObj
,
oldObj
)
{
function
diffObject
(
newObj
,
oldObj
,
every
=
true
)
{
let
result
,
key
,
cur
,
old
;
for
(
key
in
newObj
)
{
cur
=
newObj
[
key
];
old
=
oldObj
[
key
];
if
(
old
!==
cur
)
{
if
(
!
every
)
{
return
newObj
}
setResult
(
result
||
(
result
=
Object
.
create
(
null
)),
key
,
cur
);
}
}
return
result
}
function
diffArray
(
newArr
,
oldArr
)
{
const
newLen
=
newArr
.
length
;
if
(
newLen
!==
oldArr
.
length
)
{
return
newArr
}
if
(
isPlainObject
(
newArr
[
0
]))
{
for
(
let
i
=
0
;
i
<
newLen
;
i
++
)
{
if
(
diffObject
(
newArr
[
i
],
oldArr
[
i
],
false
))
{
return
newArr
}
}
}
else
{
for
(
let
i
=
0
;
i
<
newLen
;
i
++
)
{
if
(
newArr
[
i
]
!==
oldArr
[
i
])
{
return
newArr
}
}
}
}
function
diffElmData
(
newObj
,
oldObj
)
{
let
result
,
key
,
cur
,
old
;
for
(
key
in
newObj
)
{
cur
=
newObj
[
key
];
old
=
oldObj
[
key
];
if
(
old
!==
cur
)
{
if
(
key
===
'
s
'
&&
isPlainObject
(
cur
)
&&
isPlainObject
(
old
))
{
if
(
key
===
B_STYLE
&&
isPlainObject
(
cur
)
&&
isPlainObject
(
old
))
{
const
style
=
diffObject
(
cur
,
old
);
style
&&
setResult
(
result
||
(
result
=
Object
.
create
(
null
)),
'
s
'
,
style
);
style
&&
setResult
(
result
||
(
result
=
Object
.
create
(
null
)),
B_STYLE
,
style
);
}
else
if
(
key
===
V_FOR
&&
Array
.
isArray
(
cur
)
&&
Array
.
isArray
(
old
))
{
const
vFor
=
diffArray
(
cur
,
old
);
vFor
&&
setResult
(
result
||
(
result
=
Object
.
create
(
null
)),
V_FOR
,
vFor
);
}
else
{
setResult
(
result
||
(
result
=
Object
.
create
(
null
)),
key
,
cur
);
}
...
...
@@ -9260,7 +9305,7 @@ var serviceContext = (function () {
setResult
(
result
,
id
,
cur
);
continue
}
const
idObj
=
diff
Object
(
cur
,
old
);
const
idObj
=
diff
ElmData
(
cur
,
old
);
idObj
&&
setResult
(
result
,
id
,
idObj
);
}
return
result
...
...
packages/uni-app-plus/dist/view.umd.js
浏览文件 @
784d0e2b
...
...
@@ -581,7 +581,7 @@ var request_component_observer = __webpack_require__(49);
destroyComponentObserver: request_component_observer["a" /* destroyComponentObserver */]
});
// EXTERNAL MODULE: ./src/core/view/bridge/subscribe/scroll.js
var subscribe_scroll = __webpack_require__(1
3
);
var subscribe_scroll = __webpack_require__(1
2
);
// EXTERNAL MODULE: ./src/platforms/app-plus/view/bridge/subscribe/index.js
var bridge_subscribe = __webpack_require__(56);
...
...
@@ -598,7 +598,7 @@ function initSubscribe(subscribe) {
Object(bridge_subscribe["a" /* default */])(subscribe);
}
// EXTERNAL MODULE: ./src/platforms/app-plus/view/bridge.js
var bridge = __webpack_require__(1
2
);
var bridge = __webpack_require__(1
1
);
// CONCATENATED MODULE: ./src/core/view/bridge/index.js
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "on", function() { return on; });
...
...
@@ -9448,118 +9448,6 @@ function getWindowOffset() {
/* 10 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(UniViewJSBridge) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return vd; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return initData; });
/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(41);
/* harmony import */ var _vdom_sync__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(59);
/* harmony import */ var _page__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(43);
/* harmony import */ var _page_factory__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(42);
var _handleData;
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
var vd;
var PageVueComponent;
var handleData = (_handleData = {}, _defineProperty(_handleData, _constants__WEBPACK_IMPORTED_MODULE_1__[/* PAGE_CREATE */ "c"], function onPageCreate(data) {
var _data = _slicedToArray(data, 3),
pageId = _data[0],
pagePath = _data[1],
pageOptions = _data[2];
document.title = "".concat(pagePath, "[").concat(pageId, "]"); // 设置当前页面伪对象,方便其他地方使用 getCurrentPages 获取当前页面 id,route
Object(_page__WEBPACK_IMPORTED_MODULE_4__[/* setCurrentPage */ "b"])(pageId, pagePath); // 初始化当前页面 VueComponent(生成页面样式代码)
PageVueComponent = Object(_page_factory__WEBPACK_IMPORTED_MODULE_5__[/* getPageVueComponent */ "b"])(pagePath); // 生成当前页面 vd
vd = new _vdom_sync__WEBPACK_IMPORTED_MODULE_3__[/* VDomSync */ "a"](pageId); // 通知页面创建,根据当前页面配置信息,初始化部分事件
UniViewJSBridge.subscribeHandler(_constants__WEBPACK_IMPORTED_MODULE_2__[/* ON_PAGE_CREATE */ "a"], pageOptions, pageId);
}), _defineProperty(_handleData, _constants__WEBPACK_IMPORTED_MODULE_1__[/* MOUNTED_DATA */ "b"], function onMounted(data) {
vd.addVData.apply(vd, data);
}), _defineProperty(_handleData, _constants__WEBPACK_IMPORTED_MODULE_1__[/* UPDATED_DATA */ "f"], function onUpdated(data) {
vd.updateVData.apply(vd, data);
}), _defineProperty(_handleData, _constants__WEBPACK_IMPORTED_MODULE_1__[/* PAGE_CREATED */ "d"], function onPageCreated(data) {
var _data2 = _slicedToArray(data, 2),
pageId = _data2[0],
pagePath = _data2[1];
new PageVueComponent({
mpType: 'page',
pageId: pageId,
pagePath: pagePath
}).$mount('#app');
}), _handleData);
function vdSync(_ref) {
var data = _ref.data,
options = _ref.options;
var isVdCallback = true;
data.forEach(function (data) {
if (data[0] === _constants__WEBPACK_IMPORTED_MODULE_1__[/* PAGE_CREATE */ "c"]) {
// 页面创建无需触发 callback
isVdCallback = false;
}
handleData[data[0]](data[1]);
});
vd.flush();
isVdCallback && vue__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"].nextTick(function () {
UniViewJSBridge.publishHandler(_constants__WEBPACK_IMPORTED_MODULE_1__[/* VD_SYNC_CALLBACK */ "h"]);
});
}
function getData(id, name) {
try {
return this.$r[id][name];
} catch (e) {
console.error(this.$options.__file + ":[".concat(this._$id, "]$r[").concat(id, "][").concat(name, "] is undefined"));
}
}
function initData(Vue) {
Vue.prototype._$g = getData;
UniViewJSBridge.subscribe(_constants__WEBPACK_IMPORTED_MODULE_1__[/* VD_SYNC */ "g"], vdSync);
Object.defineProperty(Vue.prototype, '_$vd', {
get: function get() {
return !this.$options.isReserved && vd;
}
});
Vue.mixin({
beforeCreate: function beforeCreate() {
if (this.$options.mpType) {
this.mpType = this.$options.mpType;
}
if (this._$vd) {
this._$vd.initVm(this);
}
}
});
}
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(4)))
/***/ }),
/* 11 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// EXTERNAL MODULE: ./src/shared/index.js + 4 modules
...
...
@@ -9811,7 +9699,7 @@ function initEvents() {
}
/***/ }),
/* 1
2
*/
/* 1
1
*/
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
...
...
@@ -9852,14 +9740,14 @@ function publishHandler(event) {
}
/***/ }),
/* 1
3
*/
/* 1
2
*/
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(UniViewJSBridge) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return disableScroll; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return pageScrollTo; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return createScrollListener; });
/* harmony import */ var uni_platform_view_bridge__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1
2
);
/* harmony import */ var uni_platform_view_bridge__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1
1
);
function disableScroll(evt) {
evt.preventDefault();
...
...
@@ -9982,6 +9870,118 @@ function createScrollListener(pageId, _ref2) {
}
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(4)))
/***/ }),
/* 13 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(UniViewJSBridge) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return vd; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return initData; });
/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(41);
/* harmony import */ var _vdom_sync__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(59);
/* harmony import */ var _page__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(43);
/* harmony import */ var _page_factory__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(42);
var _handleData;
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
var vd;
var PageVueComponent;
var handleData = (_handleData = {}, _defineProperty(_handleData, _constants__WEBPACK_IMPORTED_MODULE_1__[/* PAGE_CREATE */ "c"], function onPageCreate(data) {
var _data = _slicedToArray(data, 3),
pageId = _data[0],
pagePath = _data[1],
pageOptions = _data[2];
document.title = "".concat(pagePath, "[").concat(pageId, "]"); // 设置当前页面伪对象,方便其他地方使用 getCurrentPages 获取当前页面 id,route
Object(_page__WEBPACK_IMPORTED_MODULE_4__[/* setCurrentPage */ "b"])(pageId, pagePath); // 初始化当前页面 VueComponent(生成页面样式代码)
PageVueComponent = Object(_page_factory__WEBPACK_IMPORTED_MODULE_5__[/* getPageVueComponent */ "b"])(pagePath); // 生成当前页面 vd
vd = new _vdom_sync__WEBPACK_IMPORTED_MODULE_3__[/* VDomSync */ "a"](pageId); // 通知页面创建,根据当前页面配置信息,初始化部分事件
UniViewJSBridge.subscribeHandler(_constants__WEBPACK_IMPORTED_MODULE_2__[/* ON_PAGE_CREATE */ "a"], pageOptions, pageId);
}), _defineProperty(_handleData, _constants__WEBPACK_IMPORTED_MODULE_1__[/* MOUNTED_DATA */ "b"], function onMounted(data) {
vd.addVData.apply(vd, data);
}), _defineProperty(_handleData, _constants__WEBPACK_IMPORTED_MODULE_1__[/* UPDATED_DATA */ "f"], function onUpdated(data) {
vd.updateVData.apply(vd, data);
}), _defineProperty(_handleData, _constants__WEBPACK_IMPORTED_MODULE_1__[/* PAGE_CREATED */ "d"], function onPageCreated(data) {
var _data2 = _slicedToArray(data, 2),
pageId = _data2[0],
pagePath = _data2[1];
new PageVueComponent({
mpType: 'page',
pageId: pageId,
pagePath: pagePath
}).$mount('#app');
}), _handleData);
function vdSync(_ref) {
var data = _ref.data,
options = _ref.options;
var isVdCallback = true;
data.forEach(function (data) {
if (data[0] === _constants__WEBPACK_IMPORTED_MODULE_1__[/* PAGE_CREATE */ "c"]) {
// 页面创建无需触发 callback
isVdCallback = false;
}
handleData[data[0]](data[1]);
});
vd.flush();
isVdCallback && vue__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"].nextTick(function () {
UniViewJSBridge.publishHandler(_constants__WEBPACK_IMPORTED_MODULE_1__[/* VD_SYNC_CALLBACK */ "h"]);
});
}
function getData(id, name) {
try {
return this.$r[id][name];
} catch (e) {
console.error(this.$options.__file + ":[".concat(this._$id, "]$r[").concat(id, "][").concat(name, "] is undefined"));
}
}
function initData(Vue) {
Vue.prototype._$g = getData;
UniViewJSBridge.subscribe(_constants__WEBPACK_IMPORTED_MODULE_1__[/* VD_SYNC */ "g"], vdSync);
Object.defineProperty(Vue.prototype, '_$vd', {
get: function get() {
return !this.$options.isReserved && vd;
}
});
Vue.mixin({
beforeCreate: function beforeCreate() {
if (this.$options.mpType) {
this.mpType = this.$options.mpType;
}
if (this._$vd) {
this._$vd.initVm(this);
}
}
});
}
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(4)))
/***/ }),
/* 14 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
...
...
@@ -12625,7 +12625,7 @@ function requestComponentInfo(_ref, pageId) {
"use strict";
/* WEBPACK VAR INJECTION */(function(UniViewJSBridge) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return initSubscribe; });
/* harmony import */ var uni_shared__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
/* harmony import */ var uni_core_view_bridge_subscribe_scroll__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1
3
);
/* harmony import */ var uni_core_view_bridge_subscribe_scroll__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1
2
);
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(41);
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3);
...
...
@@ -12673,7 +12673,7 @@ function initSubscribe(subscribe) {
"use strict";
/* WEBPACK VAR INJECTION */(function(UniViewJSBridge) {/* harmony import */ var uni_helpers_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7);
/* harmony import */ var _events__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1
1
);
/* harmony import */ var _events__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1
0
);
/* harmony import */ var _behaviors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(61);
/* harmony import */ var _wxs_component_descriptor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(58);
...
...
@@ -13127,7 +13127,7 @@ function initVue(Vue) {
var plugins = __webpack_require__(57);
// EXTERNAL MODULE: ./src/platforms/app-plus/view/framework/plugins/data.js
var data = __webpack_require__(1
0
);
var data = __webpack_require__(1
3
);
// CONCATENATED MODULE: ./src/platforms/app-plus/view/framework/plugins/event.js
...
...
@@ -13149,12 +13149,11 @@ function initEvent(Vue) {
};
Vue.prototype.$handleViewEvent = function ($vueEvent, options) {
var isCustomEvent = $vueEvent._processed; // 自定义事件已提前处理过
// const isCustomEvent = $vueEvent._processed // 自定义事件已提前处理过
var $event = this.$handleEvent($vueEvent);
var cid = this._$id; // 当自定义组件根节点触发事件时,nid 始终为 0
var nid =
isCustomEvent ||
$vueEvent.currentTarget === this.$el ? 0 : $event.options.nid;
var nid = $vueEvent.currentTarget === this.$el ? 0 : $event.options.nid;
if (typeof nid === 'undefined') {
return console.error("[".concat(cid, "] nid not found"));
...
...
@@ -17955,7 +17954,7 @@ function getRealPath(filePath) {
return filePath;
}
// EXTERNAL MODULE: ./src/core/view/plugins/events.js + 1 modules
var events = __webpack_require__(1
1
);
var events = __webpack_require__(1
0
);
// CONCATENATED MODULE: ./src/core/view/mixins/base.js
...
...
src/platforms/app-plus/service/framework/plugins/diff.js
浏览文件 @
784d0e2b
...
...
@@ -2,19 +2,62 @@ import {
isPlainObject
}
from
'
uni-shared
'
import
{
V_FOR
,
B_STYLE
}
from
'
../../constants
'
function
setResult
(
data
,
k
,
v
)
{
data
[
k
]
=
v
}
function
diffObject
(
newObj
,
oldObj
)
{
function
diffObject
(
newObj
,
oldObj
,
every
=
true
)
{
let
result
,
key
,
cur
,
old
for
(
key
in
newObj
)
{
cur
=
newObj
[
key
]
old
=
oldObj
[
key
]
if
(
old
!==
cur
)
{
if
(
!
every
)
{
return
newObj
}
setResult
(
result
||
(
result
=
Object
.
create
(
null
)),
key
,
cur
)
}
}
return
result
}
function
diffArray
(
newArr
,
oldArr
)
{
const
newLen
=
newArr
.
length
if
(
newLen
!==
oldArr
.
length
)
{
return
newArr
}
if
(
isPlainObject
(
newArr
[
0
]))
{
for
(
let
i
=
0
;
i
<
newLen
;
i
++
)
{
if
(
diffObject
(
newArr
[
i
],
oldArr
[
i
],
false
))
{
return
newArr
}
}
}
else
{
for
(
let
i
=
0
;
i
<
newLen
;
i
++
)
{
if
(
newArr
[
i
]
!==
oldArr
[
i
])
{
return
newArr
}
}
}
}
function
diffElmData
(
newObj
,
oldObj
)
{
let
result
,
key
,
cur
,
old
for
(
key
in
newObj
)
{
cur
=
newObj
[
key
]
old
=
oldObj
[
key
]
if
(
old
!==
cur
)
{
if
(
key
===
'
s
'
&&
isPlainObject
(
cur
)
&&
isPlainObject
(
old
))
{
if
(
key
===
B_STYLE
&&
isPlainObject
(
cur
)
&&
isPlainObject
(
old
))
{
const
style
=
diffObject
(
cur
,
old
)
style
&&
setResult
(
result
||
(
result
=
Object
.
create
(
null
)),
'
s
'
,
style
)
style
&&
setResult
(
result
||
(
result
=
Object
.
create
(
null
)),
B_STYLE
,
style
)
}
else
if
(
key
===
V_FOR
&&
Array
.
isArray
(
cur
)
&&
Array
.
isArray
(
old
))
{
const
vFor
=
diffArray
(
cur
,
old
)
vFor
&&
setResult
(
result
||
(
result
=
Object
.
create
(
null
)),
V_FOR
,
vFor
)
}
else
{
setResult
(
result
||
(
result
=
Object
.
create
(
null
)),
key
,
cur
)
}
...
...
@@ -32,7 +75,7 @@ export function diff (newData, oldData, result) {
setResult
(
result
,
id
,
cur
)
continue
}
const
idObj
=
diff
Object
(
cur
,
old
)
const
idObj
=
diff
ElmData
(
cur
,
old
)
idObj
&&
setResult
(
result
,
id
,
idObj
)
}
return
result
...
...
src/platforms/app-plus/service/framework/plugins/vdom-sync.js
浏览文件 @
784d0e2b
...
...
@@ -18,17 +18,24 @@ import {
vdSyncCallbacks
}
from
'
../subscribe-handlers/on-vd-sync-callback
'
function
wrapperEvent
(
event
)
{
event
.
preventDefault
=
noop
event
.
stopPropagation
=
noop
event
.
mp
=
event
return
Object
.
assign
({
mp
:
event
// mpvue
},
event
)
}
const
handleVdData
=
{
[
UI_EVENT
]:
function
onUIEvent
(
vdBatchEvent
,
vd
)
{
vdBatchEvent
.
forEach
(([
cid
,
nid
,
event
])
=>
{
nid
=
String
(
nid
)
event
.
preventDefault
=
noop
event
.
stopPropagation
=
noop
const
target
=
vd
.
elements
.
find
(
target
=>
target
.
cid
===
cid
&&
target
.
nid
===
nid
)
if
(
!
target
)
{
return
console
.
error
(
`event handler[
${
cid
}
][
${
nid
}
] not found`
)
}
target
.
dispatchEvent
(
event
.
type
,
event
)
target
.
dispatchEvent
(
event
.
type
,
wrapperEvent
(
event
)
)
})
}
}
...
...
src/platforms/app-plus/view/framework/plugins/event.js
浏览文件 @
784d0e2b
...
...
@@ -20,11 +20,11 @@ export function initEvent (Vue) {
}
Vue
.
prototype
.
$handleViewEvent
=
function
(
$vueEvent
,
options
)
{
const
isCustomEvent
=
$vueEvent
.
_processed
// 自定义事件已提前处理过
//
const isCustomEvent = $vueEvent._processed // 自定义事件已提前处理过
const
$event
=
this
.
$handleEvent
(
$vueEvent
)
const
cid
=
this
.
_$id
// 当自定义组件根节点触发事件时,nid 始终为 0
const
nid
=
isCustomEvent
||
(
$vueEvent
.
currentTarget
===
this
.
$el
)
?
0
:
$event
.
options
.
nid
const
nid
=
$vueEvent
.
currentTarget
===
this
.
$el
?
0
:
$event
.
options
.
nid
if
(
typeof
nid
===
'
undefined
'
)
{
return
console
.
error
(
`[
${
cid
}
] nid not found`
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录