@tarojs/runtime 3.5.2 → 3.5.3-aplha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1234,18 +1234,19 @@ class TaroElement extends TaroNode {
1234
1234
  const catchViewAlias = componentsAlias[CATCH_VIEW]._num;
1235
1235
  const _path = this._path;
1236
1236
  qualifiedName = shortcutAttr(qualifiedName);
1237
+ const qualifiedNameInCamelCase = toCamelCase(qualifiedName);
1237
1238
  const payload = {
1238
- path: `${_path}.${toCamelCase(qualifiedName)}`,
1239
+ path: `${_path}.${qualifiedNameInCamelCase}`,
1239
1240
  value: isFunction(value) ? () => value : value
1240
1241
  };
1241
1242
  hooks.call('modifySetAttrPayload', this, qualifiedName, payload, componentsAlias);
1242
1243
  if (_alias) {
1243
- const qualifiedNameAlias = _alias[qualifiedName] || qualifiedName;
1244
+ const qualifiedNameAlias = _alias[qualifiedNameInCamelCase] || qualifiedName;
1244
1245
  payload.path = `${_path}.${toCamelCase(qualifiedNameAlias)}`;
1245
1246
  }
1246
1247
  this.enqueueUpdate(payload);
1247
1248
  if (this.nodeName === VIEW) {
1248
- if (toCamelCase(qualifiedName) === CATCHMOVE) {
1249
+ if (qualifiedNameInCamelCase === CATCHMOVE) {
1249
1250
  // catchMove = true: catch-view
1250
1251
  // catchMove = false: view or static-view
1251
1252
  this.enqueueUpdate({
@@ -1293,18 +1294,19 @@ class TaroElement extends TaroNode {
1293
1294
  const pureViewAlias = componentsAlias[PURE_VIEW]._num;
1294
1295
  const _path = this._path;
1295
1296
  qualifiedName = shortcutAttr(qualifiedName);
1297
+ const qualifiedNameInCamelCase = toCamelCase(qualifiedName);
1296
1298
  const payload = {
1297
- path: `${_path}.${toCamelCase(qualifiedName)}`,
1299
+ path: `${_path}.${qualifiedNameInCamelCase}`,
1298
1300
  value: ''
1299
1301
  };
1300
1302
  hooks.call('modifyRmAttrPayload', this, qualifiedName, payload, componentsAlias);
1301
1303
  if (_alias) {
1302
- const qualifiedNameAlias = _alias[qualifiedName] || qualifiedName;
1304
+ const qualifiedNameAlias = _alias[qualifiedNameInCamelCase] || qualifiedName;
1303
1305
  payload.path = `${_path}.${toCamelCase(qualifiedNameAlias)}`;
1304
1306
  }
1305
1307
  this.enqueueUpdate(payload);
1306
1308
  if (this.nodeName === VIEW) {
1307
- if (toCamelCase(qualifiedName) === CATCHMOVE) {
1309
+ if (qualifiedNameInCamelCase === CATCHMOVE) {
1308
1310
  // catch-view => view or static-view or pure-view
1309
1311
  this.enqueueUpdate({
1310
1312
  path: `${_path}.${"nn" /* Shortcuts.NodeName */}`,
@@ -2959,10 +2961,9 @@ function getOnHideEventKey(path) {
2959
2961
  return path + '.' + ON_HIDE;
2960
2962
  }
2961
2963
  function createPageConfig(component, pageName, data, pageConfig) {
2962
- var _a, _b;
2963
2964
  // 小程序 Page 构造器是一个傲娇小公主,不能把复杂的对象挂载到参数上
2964
2965
  const id = pageName !== null && pageName !== void 0 ? pageName : `taro_page_${pageId()}`;
2965
- const [ONLOAD, ONUNLOAD, ONREADY, ONSHOW, ONHIDE, LIFECYCLES] = hooks.call('getMiniLifecycleImpl').page;
2966
+ const [ONLOAD, ONUNLOAD, ONREADY, ONSHOW, ONHIDE, LIFECYCLES, SIDE_EFFECT_LIFECYCLES] = hooks.call('getMiniLifecycleImpl').page;
2966
2967
  let pageElement = null;
2967
2968
  let unmounting = false;
2968
2969
  let prepareMountList = [];
@@ -3075,28 +3076,25 @@ function createPageConfig(component, pageName, data, pageConfig) {
3075
3076
  };
3076
3077
  });
3077
3078
  // onShareAppMessage 和 onShareTimeline 一样,会影响小程序右上方按钮的选项,因此不能默认注册。
3078
- if (component.onShareAppMessage ||
3079
- ((_a = component.prototype) === null || _a === void 0 ? void 0 : _a.onShareAppMessage) ||
3080
- component.enableShareAppMessage) {
3081
- config.onShareAppMessage = function (options) {
3082
- const target = options === null || options === void 0 ? void 0 : options.target;
3083
- if (target) {
3084
- const id = target.id;
3085
- const element = env.document.getElementById(id);
3086
- if (element) {
3087
- target.dataset = element.dataset;
3079
+ SIDE_EFFECT_LIFECYCLES.forEach(lifecycle => {
3080
+ var _a;
3081
+ if (component[lifecycle] ||
3082
+ ((_a = component.prototype) === null || _a === void 0 ? void 0 : _a[lifecycle]) ||
3083
+ component[lifecycle.replace(/^on/, 'enable')]) {
3084
+ config[lifecycle] = function (...args) {
3085
+ var _a;
3086
+ const target = (_a = args[0]) === null || _a === void 0 ? void 0 : _a.target;
3087
+ if (target === null || target === void 0 ? void 0 : target.id) {
3088
+ const id = target.id;
3089
+ const element = env.document.getElementById(id);
3090
+ if (element) {
3091
+ target.dataset = element.dataset;
3092
+ }
3088
3093
  }
3089
- }
3090
- return safeExecute(this.$taroPath, 'onShareAppMessage', options);
3091
- };
3092
- }
3093
- if (component.onShareTimeline ||
3094
- ((_b = component.prototype) === null || _b === void 0 ? void 0 : _b.onShareTimeline) ||
3095
- component.enableShareTimeline) {
3096
- config.onShareTimeline = function () {
3097
- return safeExecute(this.$taroPath, 'onShareTimeline');
3098
- };
3099
- }
3094
+ return safeExecute(this.$taroPath, lifecycle, ...args);
3095
+ };
3096
+ }
3097
+ });
3100
3098
  config.eh = eventHandler;
3101
3099
  if (!isUndefined(data)) {
3102
3100
  config.data = data;